[英]javascript regex support for UTF8 characters with Number and letters
How to generate regex for supporting utf8 characters with Numbers [0-9], letters [az] and [AZ]. 如何生成正则表达式以支持数字[0-9],字母[az]和[AZ]的utf8字符。
I am using xregexp library to support utf-8 characters. 我正在使用xregexp库来支持utf-8字符。
Till now i used : 直到现在我用:
Thanks. 谢谢。
Just use \\\\p{L}+
in combination with [0-9]
: 只需将\\\\p{L}+
与[0-9]
结合使用:
XRegExp("^(\\p{L}|[0-9])+$")
Note that you need to escape your backslash, there: \\\\
. 请注意,您需要在以下位置转义反斜杠: \\\\
。
To include _/-
: 要包含_/-
:
XRegExp("^(\\p{L}|[0-9_/-])+$")
Note that the dash ( -
) has to be the first or last character in those brackets, due to it's special meaning. 请注意,由于特殊含义,破折号( -
)必须是这些括号中的第一个或最后一个字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.