ATM I need plenty of hacks to be able to dynamically see the OP-Tree of a Regex at runtime cause use re 'debug' emits the code of a regex at compile time to STDERR.
lanx@nc10-ubuntu:~$ perl use re 'debug'; my $a=qr/(?<C>1)(?<D>2)(3)(?<A>4)/; Compiling REx "(?<C>1)(?<D>2)(3)(?<A>4)" Final program: 1: OPEN1 'C' (3) 3: EXACT <1> (5) 5: CLOSE1 'C' (7) 7: OPEN2 'D' (9) 9: EXACT <2> (11) 11: CLOSE2 'D' (13) 13: OPEN3 (15) 15: EXACT <3> (17) 17: CLOSE3 (19) 19: OPEN4 'A' (21) 21: EXACT <4> (23) 23: CLOSE4 'A' (25) 25: END (0) anchored "1234" at 0 (checking anchored) minlen 4 Freeing REx: "(?<C>1)(?<D>2)(3)(?<A>4)"
In Re^2: Is there really no @LAST_MATCH_START equivalent for named capture groups? I need to recompile a new regex within an eval while redirecting STDERR to a variable...
Thats hacky and cumbersome!
Is there any simpler or cleaner way to achieve this?
Cheers Rolf
In reply to Dynamically inspecting Regex OP-Codes at runtime? by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |