Simple regular expression

John Machin sjmachin at lexicon.net
Fri Jun 27 10:08:47 EDT 2008


On Jun 28, 12:00 am, python_enthu <srhe... at gmail.com> wrote:
> I am trying this.. what is wrong in this..
>
> IDLE 1.2.2>>> import re
> >>> a="my name is fname lname"
> >>> p=re.compile('name')
> >>> m=p.match (a)
> >>> print p.match(a)
>
> None
>
> findall() seems to work
>
> >>> print p.findall(a)
>
> ['name', 'name', 'name']

Read the manual section on the difference between match and search.



More information about the Python-list mailing list