C# Regex to allow only alpha numeric

后端 未结 6 416
野的像风
野的像风 2020-12-15 03:45

I have the following regex ^[a-zA-Z0-9]+$ which would allow alpha numeric characters. The problem here is that if I enter only numeric character like \"897687\"

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 04:42

    Just in case that the ASCII characters are at some point not enough, here the Unicode version:

    ^\p{L}[\p{L}\p{N}]*$
    

    \p{L} is any Unicode code point that has the property letter ==> Any letter from any language (that is in Unicode)

    \p{N} is any Unicode code point that has the property number ==> Any number character from any language (that is in Unicode)

提交回复
热议问题