[Tutor] String matching
Bernard Lebel
python at bernardlebel.com
Fri Nov 26 17:07:15 CET 2004
Hello,
I'm a little bit confused about the match/search methods of the string
module for regular expressions. I have looked the regular expression doc
and I can't that one simple answer.
So please excuse the basiqueness of my question, as I am used with the
.match method of JScript and it kind of matches anything....
Let say I have this string:
>>> import re
>>> mystring = 'helloworldmynameisbernardlebel'
Now I wish to attempt a match with 'bernard'.
>>> if not re.compile( 'bernard' ).match( mystring ) == None:
... print 'success'
Well, nothing gets printed. Could anyone tell me how to achieve that
simple type of matching?
Thanks in advance
Bernard
More information about the Tutor
mailing list