dames
dames

Reputation: 1481

Regular expression accepts all characters with at least five characters

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

Answers (1)

Michael Liu
Michael Liu

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

Related Questions