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.

Sign up to request clarification or add additional context in comments.

Comments

-1

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

1 Comment

Not good. If I type é, (, or ^ it won't work and maybe that's something you don't want. The question says "any characters".

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.