import re, time
text = "c a b d"
pat = re.compile( "^(?!.*__)(?=[A-Za-z])[a-z A-Z0-9_]+(?<![ _])$" )
t1 = time.time()
for i in range( 400000 ):
x = pat.match( text )
t2=time.time()
print( (t2-t1)*1000 )
aW1wb3J0IHJlLCB0aW1lCnRleHQgPSAiYyAgICAgICAgICAgICBhICAgICAgICAgICAgICAgICAgICAgIGIgICAgICAgICAgICAgICAgICAgICAgZCIKcGF0ID0gcmUuY29tcGlsZSggIl4oPyEuKl9fKSg/PVtBLVphLXpdKVthLXogQS1aMC05X10rKD88IVsgX10pJCIgKQp0MSA9IHRpbWUudGltZSgpCmZvciBpIGluIHJhbmdlKCA0MDAwMDAgKToKCXggPSBwYXQubWF0Y2goIHRleHQgKQp0Mj10aW1lLnRpbWUoKQpwcmludCggKHQyLXQxKSoxMDAwICkK