Decyphering a simple regex

后端 未结 3 1940
失恋的感觉
失恋的感觉 2020-12-04 03:26

The regular expression in question is

(\\d{3,4}[.-]?)+

sample text

707-7019-789

My progress so far

<
3条回答
  •  庸人自扰
    2020-12-04 04:10

    [.-]?
    

    What this means literally:

    character class [.-]

    • Match only one out of the following characters: . and - literally.

    lazy quantifier ?

    • Repeat the last token between 0 and 1 times, as few times as possible.

提交回复
热议问题