OK, so it looks like you're not matching.
Remember match only matches at the start of a line, so try re.search instead.
On Sun, 13 Feb 2005 17:16:24 -0800 (PST), Ron Nixon <[EMAIL PROTECTED]> wrote:
>
>
> Got the same error message after trying:
>
> x =re.match(patt,string)
> x.group()
>
> Traceback (most recent call last):
> File "C:/Python24/testphone.py", line 5, in
> -toplevel-
> x.group()
> AttributeError: 'NoneType' object has no attribute
> 'group'
>
> --- Liam Clarke <[EMAIL PROTECTED]> wrote:
>
> > Try breaking it down to
> >
> > > import re
> > > string = 'My phone is 410-995-1155'
> > > pattern = r'\d{3}-\d{3}-\d{4}'
> >
> > x = re.match(pattern, string)
> > x.group()
> >
> > See if that offers any improvement.
> >
> >
> > On Sun, 13 Feb 2005 17:01:33 -0800 (PST), Ron Nixon
> > <[EMAIL PROTECTED]> wrote:
> > > I'm dping something very simple in RE.
> > >
> > > Lets say I'm trying to match an American Phone
> > number
> > >
> > > I write the code this way and try to match it:
> > > import re
> > > string = 'My phone is 410-995-1155'
> > > pattern = r'\d{3}-\d{3}-\d{4}'
> > > re.match(pattern,string).group()
> > >
> > > but I get this error message
> > > Traceback (most recent call last):
> > > File "C:/Python24/findphone", line 4, in
> > -toplevel-
> > > re.match(pattern,string).group()
> > > AttributeError: 'NoneType' object has no attribute
> > 'group'
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Take Yahoo! Mail with you! Get it on your mobile
> > phone.
> > > http://mobile.yahoo.com/maildemo
> > > _______________________________________________
> > > Tutor maillist - [email protected]
> > > http://mail.python.org/mailman/listinfo/tutor
> > >
> >
> >
> > --
> > 'There is only one basic human right, and that is to
> > do as you damn well please.
> > And with it comes the only basic human duty, to take
> > the consequences.
> > _______________________________________________
> > Tutor maillist - [email protected]
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
> __________________________________
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile phone.
> http://mobile.yahoo.com/maildemo
>
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor