How can I create a regex for
A ten digit number whose 4th digit can't be 8 or 9?
Any help is appreciated.
我认为以下正则表达式应该做。
\d{3}[0-7]\d{6}
Something like so should work: ^\\d{3}[0-7]\\d{6}$
:
/^\d{3}[0-7]\d{6}$/
^ assert position at start of the string
\d{3} match a digit [0-9]
Quantifier: Exactly 3 times
[0-7] match a single character present in the list below
0-7 a single character in the range between 0 and 7
\d{6} match a digit [0-9]
Quantifier: Exactly 6 times
$ assert position at end of the string
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.