Regular Expression for alphanumeric and underscores

前端 未结 20 791
北荒
北荒 2020-11-22 10:01

I would like to have a regular expression that checks if a string contains only upper and lowercase letters, numbers, and underscores.

20条回答
  •  逝去的感伤
    2020-11-22 10:37

    I believe you are not taking Latin and Unicode characters in your matches. For example, if you need to take "ã" or "ü" chars, the use of "\w" won't work.

    You can, alternatively, use this approach:

    ^[A-ZÀ-Ýa-zà-ý0-9_]+$
    

    Hope it helps!

提交回复
热议问题