[EMAIL PROTECTED] wrote:

Hello all,

I am stumped on a regex problem and was wondering if some of the regex gurus
on the list wouldn't mind lending a hand.


I need a rule that will match minister but not prime minister (all /i).

I've tried looking at the negative look behind syntax but I just cant seem
to get it to work right. Any rule I can formulate still seems to hit on the
minister portion of the string.


(?<!(prime ))minister

is as close to what I can regexfully explain what I want to do but I don't
want to match minister on the above.


Thanks in advance.

Jason


Just remove the '()' inside the (?<!    ).

$ perl -e 'print "prime minister" =~ /(?<!prime )minister/,"\n"'

$ perl -e 'print "minister" =~ /(?<!prime )minister/,"\n"'
1

The problem with that regexp is if you have more than one space or something else between prime and minister it won't work (ie it will match).

Regards




Reply via email to