Regular Expression for alphanumeric and underscores

前端 未结 20 793
北荒
北荒 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:48

    For those of you looking for unicode alphanumeric matching, you might want to do something like:

    ^[\p{L} \p{Nd}_]+$
    

    Further reading at http://unicode.org/reports/tr18/ and at http://www.regular-expressions.info/unicode.html

提交回复
热议问题