<= and? = and?: What do you mean by these three kinds of things, please explain them.
Your answer is very incisive, thank you.
Write a sample for you, written in JavaScript, you say the total number of left and right numbers does not exceed 20, plus "-" that is, the total length of the string does not exceed 21. As follows:
<script type= "Text/javascript" > var str = ' 111-3763232 '; var reg =/^ (? =.{ 3,21}$) \d+-\d+$/; Alert (Reg.test (str)); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
After the test will be able to meet your requirements.
What you want to ask is the following four look around structure. They do not match any specific characters and match only one position, just as "^" and "$" match the starting and ending positions of the strings.
(?=...) A positive look in the affirmative. Where "..." is a regular expression indicating that the character to the right of the current position must be matched by "...".
(?! ...) The positive negative look around. Indicates that the content to the right of the current position must not be matched by "...".
(<= ...) and (?<!...) The difference is the reverse positive look and reverse negative look, but the direction is left.
As for (?:), it is the same as the normal bracket () function, except that it does not store the child matches. In some cases, use (?:) Can improve the efficiency of regular expressions.
To say the expression "/^" (? =.{ 3,21}$) \d+-\d+$/":
^(?=. {3,21}$) sets the starting position of the string, followed by 3-21 arbitrary characters, followed by the end of the string.
\d+-\d+$ This is your question request, there is nothing to say.