in reply to Re: reg ex NOT
in thread reg ex NOT
Remember that using * means to match zero or more times and that ? matches zero or one times, and that you can always match zero times. When you match zero times, you don't prevent anything from not matching:
print "Matched" if "dont" =~ m/don(?:(?!t).)*/;
You could anchor it so that nothing after it could match:
It's easier just to type the negated character class for that position, though:print "Matched" if "dont" =~ m/don(?:(?!t).)*$/;
print "Matched" if "dont" =~ m/don[^t]/;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: reg ex NOT
by ikegami (Patriarch) on Jun 16, 2006 at 01:33 UTC |