R
R
realt2014-08-20 19:27:14
PHP
realt, 2014-08-20 19:27:14

pattern attribute. How to correctly form the necessary expression?

A list of standard and non-standard expressions can be found here:
and here.
I need to formulate an expression so that only numbers can be entered in the form, a maximum of 4 characters, and if a person wants to enter 4 characters, then he could only enter " 1000 ". Not 1001 or 2100, just 1000 .
Tobish in the range of one, two, three characters, he can write any numbers from 0 to 9, but if he wants to enter 4 characters, then he needs to be able to enter only the number 1000.
I formed it, of course, but this option does not work :
^[0-9]\d[0-2]{0-4}
Tell me how to do it right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Petrov, 2014-08-20
@realt

(\d{1,3}|1000)

R
realt, 2014-08-20
@realt

Thanks guys :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question