[Tutor] What the difference between the two RE?

Göran Törnquist goran at usertime.se
Thu Feb 9 08:21:08 CET 2012


On 2012-02-09 08.16, Christian Witts wrote:
> 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 at 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
>

This is also a good source of information for regexp patterns in general:
http://www.regular-expressions.info/

Göran Törnquist
Usertime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120209/9d11505e/attachment.html>


More information about the Tutor mailing list