Regular Expressions?

KrayZee--J newsreply at jtwok.worldonline.co.uk
Fri Nov 29 14:47:17 EST 2002


Thanks for the reply. The problem turned out to be nothing to do with the RE
but another newbie error I was making, hey I wrote my first python program 2
days ago :) but its so easy to learn :)


"Padraig Brady" <Padraig at Linux.ie> wrote in message
news:3DE73D0D.50400 at Linux.ie...
> KrayZee--J wrote:
> > Is the Regular Expressions module really buggy or is it just me? Almost
> > every expression I type in gives an error. Many expressions which I have
> > tested and work in JScript give errors in python.
> >
> > I want to make a RE which will match an IP address. This one works in
> > JScript:
> >
> > (\d{1,3}\.){3}\d{1,3}
> >
> > In python it works but matches only 1 digit for the last octet of th IP
ie.
> > 192.168.0.100 becomes 192.168.0.1
> >
> > Any suggestions would be appreciated.
> >
> > John
> >
> >
>
> $ import re
> $ ips = "192.168.0.100sadfasf192.168.0.101adads324.23asdf192.168.0.102"
> $ re.findall("(?:\d{1,3}\.){3}\d{1,3}", ips)
> ['192.168.0.100', '192.168.0.101', '192.168.0.102']
>
> Pádraig.
>





More information about the Python-list mailing list