Purpose of the \G anchor in regular expressions

前端 未结 3 1984
死守一世寂寞
死守一世寂寞 2021-01-28 20:57

I simply don\'t understand what the \\G anchor does.

If I execute /\\G\\d\\d/ on 1122aa33, it will match 11 and

3条回答
  •  没有蜡笔的小新
    2021-01-28 21:41

    Reference link

    It basically matches from the end of the "previous match", which on the first run of a regex is considered to be the beginning of the string.

    In other words, if you ran /\G\d\d/ twice on your string 1122aa33, the second run would return a match on 22.

提交回复
热议问题