On 2012/02/09 09:44 AM, daedae11 wrote:
However, re.match("hello", "And they said hello" ) will also return None. So "And they said hello" also won't be matched by the regex pattern "hello".
------------------------------------------------------------------------
daedae11
*From:* Christian Witts <mailto:cwi...@compuscan.co.za>
*Date:* 2012-02-09 15:16
*To:* daedae11 <mailto:daeda...@126.com>
*CC:* turor_python <mailto:tutor@python.org>
*Subject:* Re: [Tutor] What the difference between the two RE?
On 2012/02/09 08:15 AM, daedae11 wrote:
import re
re.match("^hello", "hello")
re.match("hello", "hello")
Please give a string that matches RE "^hello" but does not match RE "hello", or matches RE "hello" but does not match RE "^hello".
------------------------------------------------------------------------
daedae11


_______________________________________________
Tutor maillist  -Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
The caret ^ means "At the beginning of the line" so 'And they said hello' will not be matched by the regex pattern '^hello'.

The docs are pretty good on the module
http://docs.python.org/library/re.html
http://docs.python.org/howto/regex.html
--

Christian Witts
Python Developer
//

--
From the docs http://docs.python.org/library/re.html#re.match
Note: If you want to locate a match anywhere in string, use search() instead.
--

Christian Witts
Python Developer
//
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to