Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Force POSIX NFA in Perl?

Reply
Thread Tools

Force POSIX NFA in Perl?

 
 
Ivan Fomichev
Guest
Posts: n/a
 
      07-15-2005
Hello, All!

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.
The perfect solution would be switching on POSIX NFA lexically. Is it
possible?

WBR,
Ivan.

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      07-15-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nike air force one, air force 1, air force one low cut, air force one abdul_razak@indiatimes.com Digital Photography 2 12-31-2008 04:29 PM
Nike Air Force Ones,Air Force One Air Force One-1 lky52193@gmail.com Computer Support 0 01-17-2008 04:40 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:46 PM
Nike Air Force Ones,Air Force One Air Force One-1,25th anniversary lky52112@gmail.com Digital Photography 0 01-15-2008 04:34 PM
NFA to DFA r C++ 6 01-14-2004 10:21 PM



Advertisments