On Tue, Oct 01, 2002 at 01:24:45PM -0600, Luke Palmer wrote:
> 
> > [Negative matching]
> 
> > a generic negative, multi-byte string matching mechanism. Any thoughts? 
> > Am I missing something already present or otherwise obvious?
> 
> Maybe I'm misundertanding the question, but I think you want negative
> lookahead:
> 
> Perl 5:   /(.*)(?!>union)/
> Perl 6:   /(.*) <!before: union>/
> 
> Luke

no, that doesn't work, because of the way regexes operate. The '.*' captures 
everything, and since the string after everything (ie: the end of the string)
doesn't match 'union', the regex succeeds without backtracking. Try it:

perl -e ' $a = "this has the string union in it"; my ($b) = ($a =~ m"(.*)(?!>union)"); 
print $b;'

prints: 

this has the string union in it

not 'this has the string'.

Ed

Reply via email to