开发者

Regular expression to match nine-digit numbers that start with a 1

开发者 https://www.devze.com 2023-01-25 16:40 出处:网络
I am trying to match 9-digit numbers that start with a 1 \"/^1[0-9]{9}$/开发者_如何转开发\" /^1\\d{8}/

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].

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号