How can I match overlapping strings with regex?

后端 未结 6 1752
猫巷女王i
猫巷女王i 2020-11-22 03:27

Let\'s say I have the string

\"12345\"

If I .match(/\\d{3}/g), I only get one match, \"123\". Why don\'t I get

6条回答
  •  被撕碎了的回忆
    2020-11-22 03:46

    When an expression matches, it usually consumes the characters it matched. So, after the expression matched 123, only 45 is left, which doesn't match the pattern.

提交回复
热议问题