On Jun 27, 11:05 am, "John Salerno" <johnj...@NOSPA Mgmail.comwrote :
Thanks John Salerno and John Machin,
I am used to perl. So I guess I am better of using re.search instead
of re.match
BTW, is re.search('stri ng') equivalent to re.match ('^string')
"python_ent hu" <srhe...@gmail. comwrote in message
>
news:47031cc4-2b5e-43b3-9338-cf4a7b4c1568@d4 5g2000hsc.googl egroups.com...
>
>
>
match( string[, pos[, endpos]])
>
If zero or more characters at the beginning of string match this regular
expression, return a corresponding MatchObject instance. Return None if the
string does not match the pattern; note that this is different from a
zero-length match.
>
search( string[, pos[, endpos]])
>
Scan through string looking for a location where this regular expression
produces a match, and return a corresponding MatchObject instance. Return
None if no position in the string matches the pattern; note that this is
different from finding a zero-length match at some point in the string.
>
news:47031cc4-2b5e-43b3-9338-cf4a7b4c1568@d4 5g2000hsc.googl egroups.com...
>
I am trying this.. what is wrong in this..
IDLE 1.2.2
None
>>import re
>>a="my name is fname lname"
>>p=re.compile( 'name')
>>m=p.match (a)
>>print p.match(a)
>>a="my name is fname lname"
>>p=re.compile( 'name')
>>m=p.match (a)
>>print p.match(a)
match( string[, pos[, endpos]])
>
If zero or more characters at the beginning of string match this regular
expression, return a corresponding MatchObject instance. Return None if the
string does not match the pattern; note that this is different from a
zero-length match.
>
search( string[, pos[, endpos]])
>
Scan through string looking for a location where this regular expression
produces a match, and return a corresponding MatchObject instance. Return
None if no position in the string matches the pattern; note that this is
different from finding a zero-length match at some point in the string.
I am used to perl. So I guess I am better of using re.search instead
of re.match
BTW, is re.search('stri ng') equivalent to re.match ('^string')
Comment