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

2013-01-07 Thread Steven D'Aprano
On Mon, 07 Jan 2013 01:45:58 -0800, iMath wrote: > 在 2012年9月26日星期三UTC+8下午3时38分50秒,iMath写道: >> 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() ? > > I thought re.match('h.$', 'hbxihi') will matc

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

2013-01-07 Thread iMath
在 2012年9月26日星期三UTC+8下午3时38分50秒,iMath写道: > 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() > ? I thought re.match('h.$', 'hbxihi') will match ‘hi’ ,but it does not .so why ? -- http://mail.python.or

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

2012-09-28 Thread Ian Kelly
On Fri, Sep 28, 2012 at 12:07 PM, Prasad, Ramit 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 obje

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

2012-09-28 Thread Prasad, Ramit
iMath wrote: > Sent: Wednesday, September 26, 2012 2:39 AM > To: python-list@python.org > Subject: regular expression : the dollar sign ($) work with re.match() or > re.search() ? > > I only know the dollar sign ($) will match a pattern from the > end of a string,but whic

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

2012-09-26 Thread Jussi Piitulainen
Alister writes: > On Wed, 26 Sep 2012 10:48:00 +0300, Jussi Piitulainen wrote: > > > 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.m

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

2012-09-26 Thread Alister
On Wed, 26 Sep 2012 10:48:00 +0300, Jussi Piitulainen wrote: > 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

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

2012-09-26 Thread Peter Otten
iMath wrote: > 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() ? Why not try it out in the interactive interpreter? Here's the "deluxe version": >>> def demo(pattern="mid$", texts=["start mid end",

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

2012-09-26 Thread Chris Angelico
On Wed, Sep 26, 2012 at 5:48 PM, Jussi Piitulainen wrote: > What was the weird character that you used as a question mark? I > removed them because they confuse the newsreader I use. It appears to be Unicode Character 'FULLWIDTH QUESTION MARK' (U+FF1F). Normally I'd be inclined to simply use U+00

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

2012-09-26 Thread Jussi Piitulainen
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 (o

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

2012-09-26 Thread iMath
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() ? -- http://mail.python.org/mailman/listinfo/python-list