in reply to Regex code block executes twice per match using look-arounds
After several unsuccessful attempts, the engine finds a match starting at position 4:
Setting an EVAL scope, savestack=25 4 <{x1}> <[x2]> | 1: IFMATCH[-1] 3 <{x1> <}[x2]> | 3: OPEN1 3 <{x1> <}[x2]> | 5: ANYOF[)>\]}] 4 <{x1}> <[x2]> | 16: CLOSE1 4 <{x1}> <[x2]> | 18: SUCCEED could match... 4 <{x1}> <[x2]> | 20: IFMATCH[-0] 4 <{x1}> <[x2]> | 22: OPEN2 4 <{x1}> <[x2]> | 24: ANYOF[(<[{] 5 <{x1}[> <x2]> | 35: CLOSE2 5 <{x1}[> <x2]> | 37: SUCCEED could match... 4 <{x1}> <[x2]> | 39: EVAL re_eval 0x10033008 Match 1: left }, right [ 4 <{x1}> <[x2]> | 41: END Match successful!
Then it starts again at position 4, and matches again but then throws it away:
The whole output looks like this:Setting an EVAL scope, savestack=37 4 <{x1}> <[x2]> | 1: IFMATCH[-1] 3 <{x1> <}[x2]> | 3: OPEN1 3 <{x1> <}[x2]> | 5: ANYOF[)>\]}] 4 <{x1}> <[x2]> | 16: CLOSE1 4 <{x1}> <[x2]> | 18: SUCCEED could match... 4 <{x1}> <[x2]> | 20: IFMATCH[-0] 4 <{x1}> <[x2]> | 22: OPEN2 4 <{x1}> <[x2]> | 24: ANYOF[(<[{] 5 <{x1}[> <x2]> | 35: CLOSE2 5 <{x1}[> <x2]> | 37: SUCCEED could match... 4 <{x1}> <[x2]> | 39: EVAL re_eval 0x10033008 Match 2: left }, right [ 4 <{x1}> <[x2]> | 41: END Match possible, but length=0 is smaller than requested=1, failing!
Compiling REx `[]>})]' size 12 Got 100 bytes for offset annotations. first at 1 1: ANYOF[)>\]}](12) 12: END(0) stclass `ANYOF[)>\]}]' minlen 1 Offsets: [12] 1[6] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 7[0] Compiling REx `[[<{(]' size 12 Got 100 bytes for offset annotations. first at 1 1: ANYOF[(<[{](12) 12: END(0) stclass `ANYOF[(<[{]' minlen 1 Offsets: [12] 1[6] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 7[0] Compiling REx ` (?<=((?-xism:[]>})]))) (?=((?-xism:[[<{(]))) (?{print qq{Match @{ [++ $count] }: left $1, right $2\n}}) ' size 41 Got 332 bytes for offset annotations. first at 1 1: IFMATCH[-1](20) 3: OPEN1(5) 5: ANYOF[)>\]}](16) 16: CLOSE1(18) 18: SUCCEED(0) 19: TAIL(20) 20: IFMATCH[-0](39) 22: OPEN2(24) 24: ANYOF[(<[{](35) 35: CLOSE2(37) 37: SUCCEED(0) 38: TAIL(39) 39: EVAL(41) 41: END(0) minlen 0 with eval Offsets: [41] 9[17] 0[0] 9[1] 0[0] 18[6] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] + 0[0] 0[0] 25[1] 0[0] 25[0] 25[0] 34[17] 0[0] 34[1] 0[0] 43[6] 0[0] 0 +[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 50[1] 0[0] 50[0] 50[0] 56 +[59] 0[0] 115[0] Before: {x1}[x2] ---------------------------------------- Matching REx ` (?<=((?-xism:[]>})]))) (?=((?-xism:[[<{(]))) (?{print qq{Match @{ [++ $count] }: left $1, right $2\n}}) ...' against `{x1}[x2]' Setting an EVAL scope, savestack=25 0 <> <{x1}[x2]> | 1: IFMATCH[-1] failed... Setting an EVAL scope, savestack=25 1 <{> <x1}[x2]> | 1: IFMATCH[-1] 0 <> <{x1}[x2]> | 3: OPEN1 0 <> <{x1}[x2]> | 5: ANYOF[)>\]}] failed... failed... Setting an EVAL scope, savestack=25 2 <{x> <1}[x2]> | 1: IFMATCH[-1] 1 <{> <x1}[x2]> | 3: OPEN1 1 <{> <x1}[x2]> | 5: ANYOF[)>\]}] failed... failed... Setting an EVAL scope, savestack=25 3 <{x1> <}[x2]> | 1: IFMATCH[-1] 2 <{x> <1}[x2]> | 3: OPEN1 2 <{x> <1}[x2]> | 5: ANYOF[)>\]}] failed... failed... Setting an EVAL scope, savestack=25 4 <{x1}> <[x2]> | 1: IFMATCH[-1] 3 <{x1> <}[x2]> | 3: OPEN1 3 <{x1> <}[x2]> | 5: ANYOF[)>\]}] 4 <{x1}> <[x2]> | 16: CLOSE1 4 <{x1}> <[x2]> | 18: SUCCEED could match... 4 <{x1}> <[x2]> | 20: IFMATCH[-0] 4 <{x1}> <[x2]> | 22: OPEN2 4 <{x1}> <[x2]> | 24: ANYOF[(<[{] 5 <{x1}[> <x2]> | 35: CLOSE2 5 <{x1}[> <x2]> | 37: SUCCEED could match... 4 <{x1}> <[x2]> | 39: EVAL re_eval 0x10033008 Match 1: left }, right [ 4 <{x1}> <[x2]> | 41: END Match successful! Matching REx ` (?<=((?-xism:[]>})]))) (?=((?-xism:[[<{(]))) (?{print qq{Match @{ [++ $count] }: left $1, right $2\n}}) ...' against `[x2]' Setting an EVAL scope, savestack=37 4 <{x1}> <[x2]> | 1: IFMATCH[-1] 3 <{x1> <}[x2]> | 3: OPEN1 3 <{x1> <}[x2]> | 5: ANYOF[)>\]}] 4 <{x1}> <[x2]> | 16: CLOSE1 4 <{x1}> <[x2]> | 18: SUCCEED could match... 4 <{x1}> <[x2]> | 20: IFMATCH[-0] 4 <{x1}> <[x2]> | 22: OPEN2 4 <{x1}> <[x2]> | 24: ANYOF[(<[{] 5 <{x1}[> <x2]> | 35: CLOSE2 5 <{x1}[> <x2]> | 37: SUCCEED could match... 4 <{x1}> <[x2]> | 39: EVAL re_eval 0x10033008 Match 2: left }, right [ 4 <{x1}> <[x2]> | 41: END Match possible, but length=0 is smaller than requested=1, failing! Clearing an EVAL scope, savestack=37..40 Setting an EVAL scope, savestack=37 5 <{x1}[> <x2]> | 1: IFMATCH[-1] 4 <{x1}> <[x2]> | 3: OPEN1 4 <{x1}> <[x2]> | 5: ANYOF[)>\]}] failed... failed... Setting an EVAL scope, savestack=37 6 <{x1}[x> <2]> | 1: IFMATCH[-1] 5 <{x1}[> <x2]> | 3: OPEN1 5 <{x1}[> <x2]> | 5: ANYOF[)>\]}] failed... failed... Setting an EVAL scope, savestack=37 7 <{x1}[x2> <]> | 1: IFMATCH[-1] 6 <{x1}[x> <2]> | 3: OPEN1 6 <{x1}[x> <2]> | 5: ANYOF[)>\]}] failed... failed... Setting an EVAL scope, savestack=37 8 <{x1}[x2]> <> | 1: IFMATCH[-1] 7 <{x1}[x2> <]> | 3: OPEN1 7 <{x1}[x2> <]> | 5: ANYOF[)>\]}] 8 <{x1}[x2]> <> | 16: CLOSE1 8 <{x1}[x2]> <> | 18: SUCCEED could match... 8 <{x1}[x2]> <> | 20: IFMATCH[-0] 8 <{x1}[x2]> <> | 22: OPEN2 8 <{x1}[x2]> <> | 24: ANYOF[(<[{] failed... failed... Match failed ---------------------------------------- After: {x1}+[x2] Freeing REx: `"[]>})]"' Freeing REx: `"[[<{(]"' Freeing REx: `"\n (?<=((?-xism:[]>})])))\n (?=((?-xism:[[<{(])))\n + ("......'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex code block executes twice per match using look-arounds
by johngg (Canon) on Jul 12, 2007 at 19:39 UTC | |
by mrpeabody (Friar) on Jul 14, 2007 at 03:35 UTC |