in reply to Re: Using a capture in /(?{...})/
in thread Using a capture in /(?{...})/
I spoke too soon, kinda.
pos works, but gives a weird warning when + is used:
use strict; use warnings; my $re0; my $re1; our $s_pos; $re1 = qr/ (?{ local $s_pos = pos; }) [A-Z] (?{ print("[", substr($_, $s_pos, pos()-$s_pos), "]\n") }) /x; $re0 = qr/ (?: (??{ $re1 }) )+ /x; 'abcDE' =~ $re0; __END__ output ====== (?: (??{ $re1 }) )+ matches null string many times before HERE mark in regex m/ (?: (??{ $re1 }) )+ << HERE / at script.pl line 19. [D] [E]
Same with the extra capture:
use strict; use warnings; my $re0; my $re1; $re1 = qr/ ([A-Z]) (?{ print("[$1]\n") }) /x; $re0 = qr/ (?: () (??{ $re1 }) )+ /x; 'abcDE' =~ $re0; __END__ (?: () (??{ $re1 }) )+ matches null string many times before HERE mark in regex m/ (?: () (??{ $re1 }) )+ << HERE / at script.pl line 17. [D] [E]
However, the warning seems to be spurious. The warning check is using a variable that's not updated, but the pos truly is changing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using a capture in /(?{...})/
by japhy (Canon) on Jul 25, 2005 at 22:09 UTC | |
by ikegami (Patriarch) on Jul 26, 2005 at 00:07 UTC |