Reputation: 3349
Can someone please explain what the following regular expression means?
^(?=.*[\p{L}\p{M}0-9]).{6,50}$
It forces users to have at least one number in their username.
How should I modify it to remove this constraint?
Upvotes: 2
Views: 131
Reputation: 626748
You need to remove the 0-9
constraint set in the look-ahead:
^(?=.*[\p{L}\p{M}]).{6,50}$
Now, it allows a string containing any symbols but a newline, from 6 to 50 occurrences, and at least one Unicode letter.
To use it in Java, you need to double-escape backslashes:
String pattern = "^(?=.*[\\p{L}\\p{M}]).{6,50}$";
Upvotes: 1