2

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.

2 Answers 2

7

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

.{5,}

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

-1

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

1
  • 2
    Not good. If I type é, (, or ^ it won't work and maybe that's something you don't want. The question says "any characters". May 2, 2012 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.