Python: Regular expression to match alpha-numeric not working?

前端 未结 3 1700
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 10:15

I am looking to match a string that is inputted from a website to check if is alpha-numeric and possibly contains an underscore. My code:

if re.match(\'[a-zA         


        
3条回答
  •  囚心锁ツ
    2021-01-01 10:51

    Your regex only matches one character. Try this instead:

    if re.match('^[a-zA-Z0-9_]+$',playerName): 
    

提交回复
热议问题