Adi
Adi

Reputation: 4022

Regex pattern for 'minimum of 5 characters' for an HTML form

I am just using HTML forms for the first time and I want to use the new pattern attribute. This is a regular expression (which I haven't used before) so I am a bit lost. The basic rule I want is 'minimum 5 of any characters'

I have tried:

pattern="([0-9][A-Z]){5}"

but this doesn't work, so I am obviously missing something.

Upvotes: 2

Views: 3122

Answers (2)

user237419
user237419

Reputation: 9064

Use this, instead: [0-9a-zA-Z]{5,}

Upvotes: -1

alex
alex

Reputation: 490263

The basic rule I want is 'minimum 5 of any characters'

.{5,}

This will match any character (except \n) at least 5 times.

Upvotes: 7

Related Questions