I simply don’t understand what the \G anchor does.
If I execute /\G\d\d/ on 1122aa33, it will match 11 and 22. However, when I try /\d\d\G/ on 1122aa33, it matches nothing.
Can someone enlighten me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
\Gis an anchor which matches the previous match position.On the first pass,
\Gis equivalent to\A, which is the start of the string anchor. Since\d\d\Awill never match anything (because how can you have two digits before the start of the string?),\d\d\Gwill also never match anything.