I am trying to match 9-digit numbers that start with a 1
"/^1[0-9]{9}$/开发者_如何转开发"
/^1\d{8}/
The first number 1
will be your first digit, so the quantifier should be 8.
^(?=1)\d{9}$
The space is \s
If you need 9 numbers starting with one then you only need to limit the repetition of the character class to eight (8):
"/^1[0-9]{8}$/"
In your sample you have "\ ". If you need to allow spaces use a space or \s
for whitespace: [0-9 ]
or [0-9\s]
.
精彩评论