I am learning regex and i have a case related to backreference.
- e.g. with
(a)(b)\g{2}
will match the resultabb
- however for the case
\g{2}(a)(b)
I haven't found a match yet. - I don't know why either. Can anyone explain to me how this backreference works. thank you very much. Sorry for my bad English
I tried replacing index 2 with 3 or less than 1, but it gives regex syntax error. It can be understood that here only two indexes are allowed, 1 and 2, corresponding to the positions of the 2 existing groups. however with \g{2}(a)(b)
the results like bab
or aab
or ab
do not match