Nice idea, thanks! I'm using /(?:)/ for now. It's still a bit of a workaround though, since it affects the debug output - you see a lot of "Matching REx "(?:)"" instead of "Matching REx """:
use warnings;
use strict;
'g'=~/g/;
my $regex = 'm{}g'; # user input
my $text = 'x'; # user input
eval qq{
use re 'debug';
''=~/(?:)/;
print "<\$&>\\n" while \$text =~ $regex;
};
__END__
Compiling REx "(?:)"
Final program:
1: NOTHING (2)
2: END (0)
minlen 0
Compiling REx ""
Final program:
1: NOTHING (2)
2: END (0)
minlen 0
Matching REx "(?:)" against ""
0 <> <> | 0| 1:NOTHING(2)
0 <> <> | 0| 2:END(0)
Match successful!
Matching REx "(?:)" against "x"
0 <> <x> | 0| 1:NOTHING(2)
0 <> <x> | 0| 2:END(0)
Match successful!
<>
Matching REx "(?:)" against "x"
0 <> <x> | 0| 1:NOTHING(2)
0 <> <x> | 0| 2:END(0)
Match possible, but length=0 is smaller than requested=1, failing!
1 <x> <> | 0| 1:NOTHING(2)
1 <x> <> | 0| 2:END(0)
Match successful!
<>
Matching REx "(?:)" against ""
1 <x> <> | 0| 1:NOTHING(2)
1 <x> <> | 0| 2:END(0)
Match possible, but length=0 is smaller than requested=1, failing!
Match failed
Freeing REx: ""
Freeing REx: "(?:)"
|