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".

re.match always matches the beginning of the string, so

    re.match("^hello", something)
    re.match("hello", something)

are identical.

re.search will search anywhere in the string, not just the beginning, so:

    re.search("^hello", something)

means "find the beginning of the string followed by h e l l o"

while

    re.search("hello", something)

means "find h e l l o anywhere in the string".



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

Reply via email to