开发者

How to validate username using regexp?

开发者 https://www.devze.com 2023-01-24 15:19 出处:网络
How validate username using regexp ? For English letters, Numbers and spaces I am usi开发者_JS百科ng :

How validate username using regexp ?

For English letters, Numbers and spaces I am usi开发者_JS百科ng :

/^[a-zA-Z]{1}([a-zA-Z0-9]|\s(?!\s)){4,14}[^\s]$/

How can i add arabic letters ?


Well that would depend if your characters are coming in as cp1256 or unicode. If its unicode you can use the range such as #([\x{0600}-\x{06FF}]+\s*) in your expression.


you would use unicode regexes and match all letters:

/\pL+/u

(one or more letters)

0

精彩评论

暂无评论...
验证码 换一张
取 消