java - Regular expression for a string containing at least one number -


can please explain following regular expression means?

^(?=.*[\p{l}\p{m}0-9]).{6,50}$ 

it forces users have @ least 1 number in username.

how should modify remove constraint?

you need remove 0-9 constraint set in look-ahead:

^(?=.*[\p{l}\p{m}]).{6,50}$ 

now, allows string containing symbols newline, 6 50 occurrences, , @ least 1 unicode letter.

to use in java, need double-escape backslashes:

string pattern = "^(?=.*[\\p{l}\\p{m}]).{6,50}$"; 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -