regexr icon indicating copy to clipboard operation
regexr copied to clipboard

Incorrect explanation for duplicate groups

Open lukedan opened this issue 4 years ago • 2 comments
trafficstars

For this expression: (?|a(b)(c))\2, (b) is the first captured group, while (c) is the second captured group. This expression would match abcc. However, the explanation given by regexr says that both are capturing group 1, and indicates that group 2 does not exist. This is not consistent with PCRE rules.

lukedan avatar Jul 09 '21 05:07 lukedan

For reference: https://regexr.com/61jrr

It looks like our parser isn't handling branch reset groups (?|...) correctly - it's resetting on each group, instead of on a |.

gskinner avatar Jul 09 '21 15:07 gskinner

i know why it is happening main reason for this happening as per you stated """ For this expression: (?|a(b)(c))\2, (b) is the first captured group, while (c) is the second captured group. This expression would match abcc. However, the explanation given by regexr says that both are capturing group 1, and indicates that group 2 does not exist. This is not consistent with PCRE rules.""" but it can although fit easily so don't worry it problem continues then let me know i will handle Best Luck 👍

Prash8830 avatar Jul 15 '21 08:07 Prash8830