Re: Force POSIX NFA in Perl?
- From: Brian McCauley <nobull@xxxxxxxx>
- Date: Fri, 15 Jul 2005 17:46:15 +0100
Ivan Fomichev wrote:
I need to make Perl regex engine search over all possibilities to make
my '(?{})'
constructions work properly. It could be done by putting something like
'$(?{$match=1})(?<!$)' at the end of a regex. But it looks ugly and
annoys me.
Well the conventional 'always false' assertion is simply (?!) which is marginally less ugly than (?<!$).
Appart from that you can of course put the suffix in a variable.
my $nfa = qr/(?{$match=1})(?!)/;or write a subroutine
sub nfa {
local our $match;
my $suffix = qr/(?{$match=1})(?!)/;
$_[0] =~ /$_[1]$suffix/;
$match;
}{
local our @substrings;
nfa 'ABC' => qr/(.+?)(?{ push @substrings => $1})/;
print "@substrings\n";
}The perfect solution would be switching on POSIX NFA lexically.
Seems overkill to add yet another a feature to core Perl when it can be achieved relatively simply already.
.
- References:
- Force POSIX NFA in Perl?
- From: Ivan Fomichev
- Force POSIX NFA in Perl?
- Prev by Date: format results of duplicate ldapsearch records
- Next by Date: Re: Getting 'system' to Process Win32 Paths Correctly
- Previous by thread: Force POSIX NFA in Perl?
- Next by thread: FAQ 4.3 Why isn't my octal data interpreted correctly?
- Index(es):
Relevant Pages
|