How to Regex a string

前端 未结 2 397
南方客
南方客 2021-01-23 09:49

Is it possible to check with regex:

  1. the complete string are numbers AND
  2. the first character is a 7 or 8 then the complete length of the st
2条回答
  •  情歌与酒
    2021-01-23 10:39

    Here's the regex: /^[78]\d{10}$/

    "^" indicates the start of the line "$" indicates the end of the line \d means digits {10}means exactly 10 [] is a group of valid values

    The second question is dependant on wether your Engine supports Lookahead and Lookbehind https://www.regular-expressions.info/conditional.html

提交回复
热议问题