Reputation: 1481
I've seen the following regular expression around the web.
(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
It validates only if the string:
But I am trying to make it contain at least 5 characters while allowing the user to use whichever characters they choose.
Upvotes: 1
Views: 2762
Reputation: 55389
The regular expression .{5}
will match any string containing at least five characters. Note that, other than newlines, the characters can be anything, so a string consisting of five spaces will match.
Upvotes: 1