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

Ian Kelly ian.g.kelly at gmail.com
Fri Sep 28 14:32:07 EDT 2012


On Fri, Sep 28, 2012 at 12:07 PM, Prasad, Ramit
<ramit.prasad at jpmorgan.com> wrote:
> I guess you can consider re.match's pattern to be
> prefixed with '^'.

You can in this case, but they're not equivalent in multi-line mode:

>>> re.match('^two', 'one\ntwo', re.M)
>>> re.search('^two', 'one\ntwo', re.M)
<_sre.SRE_Match object at 0x0475BFA8>



More information about the Python-list mailing list