regular expression : the dollar sign ($) work with re.match() or re.search()

Jussi Piitulainen jpiitula at ling.helsinki.fi
Wed Sep 26 03:48:00 EDT 2012


iMath writes:

> I only know the dollar sign ($) will match a pattern from the end of
> a string, but which method does it work with, re.match() or
> re.search()

It works with both. With re.match, the pattern has to match at the
start of the string _and_ the $ has to match the end of the string (or
a line); re.search scans the string until it finds a suitable start.

What was the weird character that you used as a question mark? I
removed them because they confuse the newsreader I use.



More information about the Python-list mailing list