Matching zero only once using RE
Mike Meyer
mwm at mired.org
Fri Oct 7 13:53:10 EDT 2005
"GregM" <gregm at taming-tech.com> writes:
> I've looked at a lot of pages on the net and still can't seem to nail
> this. Would someone more knowledgeable in regular expressions please
> provide some help to point out what I'm doing wrong?
>
> I am trying to see if a web page contains the exact text:
> You have found 0 matches
Why in the gods names are you using an re for this? Just use in:
>>> pretext1 = 'This is some text with You have found 0 matches in it'
>>> pretext2 = 'This text should not match'
>>> 'You have found 0 matches' in pretext1
True
>>> 'You have found 0 matches' in pretext2
False
>>>
I think it's time to form a Committee for the Prevention of Regular
Expression Abuse.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list