how to do exact match for all characters using re.match()

Christos TZOTZIOY Georgiou DLNXPEGFQVEB at spammotel.com
Tue Aug 6 03:24:13 EDT 2002


smandava at cosinecom.com (Srikanth) wrote in message news:<563c8e6a.0208051737.3769d681 at posting.google.com>...
> Hi,
> 
> I'm using the method re.match(<regex>, string) to find a match. But I
> want all characters of <string> to match the regex. I'm getting a
> match if 0 or more characters are a match. Is there a way to make the
> whole string match the regex?
> 
> Thanks
> Srikanth

You should add a '$' at the end of the regular expression.  This
matches the end of the searched text.

For example, if you try to match the string "aaab" against /a+/, you
have a match, but if you match it against /a+$/, then you don't have a
match.
Try reading more information about regular expressions.



More information about the Python-list mailing list