in reply to Re^3: Leaking Regex Captures
in thread Leaking Regex Captures
Perhaps a stepwise commented example would make it clear what my issue is.
$1 should be 'a' at this point.Matching REx "(?:(.)b|.)+" against "abc" 0 <> <abc> | 1:CURLYX[0] {1,32767}(15) 0 <> <abc> | 14: WHILEM[1/1](0) whilem: matched 0 out of 1..32767 0 <> <abc> | 3: BRANCH(11) 0 <> <abc> | 4: OPEN1(6) 0 <> <abc> | 6: REG_ANY(7) 1 <a> <bc> | 7: CLOSE1(9)
$1 might be 'c' at this point1 <a> <bc> | 9: EXACTF <b>(14) 2 <ab> <c> | 14: WHILEM[1/1](0) whilem: matched 1 out of 1..32 +767 2 <ab> <c> | 3: BRANCH(11) 2 <ab> <c> | 4: OPEN1(6) 2 <ab> <c> | 6: REG_ANY(7) 3 <abc> <> | 7: CLOSE1(9)
$1 should have been restored to 'a' at this point due to the backtracking.3 <abc> <> | 9: EXACTF <b>(14) failed... 2 <ab> <c> | 11: BRANCH(13)
2 <ab> <c> | 12: REG_ANY(14) 3 <abc> <> | 14: WHILEM[1/1](0) whilem: matched 2 out of 1 +..32767 3 <abc> <> | 3: BRANCH(11) 3 <abc> <> | 4: OPEN1(6) 3 <abc> <> | 6: REG_ANY(7) failed... 3 <abc> <> | 11: BRANCH(13) 3 <abc> <> | 12: REG_ANY(14) failed... BRANCH failed... whilem: failed, trying con +tinuation... 3 <abc> <> | 15: NOTHING(16) 3 <abc> <> | 16: END(0) Match successful! Test: $1='c', $2=''
$1 might be 'a' at this pointMatching REx "(?:(.)b|.)+" against "ac" 0 <> <ac> | 1:CURLYX[0] {1,32767}(15) 0 <> <ac> | 14: WHILEM[1/1](0) whilem: matched 0 out of 1..32767 0 <> <ac> | 3: BRANCH(11) 0 <> <ac> | 4: OPEN1(6) 0 <> <ac> | 6: REG_ANY(7) 1 <a> <c> | 7: CLOSE1(9)
$1 should have been restored to undef at this point, due to the backtracking1 <a> <c> | 9: EXACTF <b>(14) failed... 0 <> <ac> | 11: BRANCH(13)
0 <> <ac> | 12: REG_ANY(14) 1 <a> <c> | 14: WHILEM[1/1](0) whilem: matched 1 out of 1..32 +767 1 <a> <c> | 3: BRANCH(11) 1 <a> <c> | 4: OPEN1(6) 1 <a> <c> | 6: REG_ANY(7) 2 <ac> <> | 7: CLOSE1(9) 2 <ac> <> | 9: EXACTF <b>(14) failed... 1 <a> <c> | 11: BRANCH(13) 1 <a> <c> | 12: REG_ANY(14) 2 <ac> <> | 14: WHILEM[1/1](0) whilem: matched 2 out of 1 +..32767 2 <ac> <> | 3: BRANCH(11) 2 <ac> <> | 4: OPEN1(6) 2 <ac> <> | 6: REG_ANY(7) failed... 2 <ac> <> | 11: BRANCH(13) 2 <ac> <> | 12: REG_ANY(14) failed... BRANCH failed... whilem: failed, trying con +tinuation. .. 2 <ac> <> | 15: NOTHING(16) 2 <ac> <> | 16: END(0) Match successful! Test: $1='', $2=''
|
|---|