faressoft
faressoft

Reputation: 19651

How to validate username using regexp?

How validate username using regexp ?

For English letters, Numbers and spaces I am using :

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

How can i add arabic letters ?

Upvotes: 0

Views: 555

Answers (2)

superfro
superfro

Reputation: 3302

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.

Upvotes: 6

knittl
knittl

Reputation: 265547

you would use unicode regexes and match all letters:

/\pL+/u

(one or more letters)

Upvotes: 4

Related Questions