re question

Dan Bar Dov bardov at gmail.com
Wed Sep 19 08:17:16 EDT 2007


I'm trying to construct a regular expression to match valid IP address,
without leading zeroes (i.e
1.2.3.4, 254.10.0.0, but not 324.1.1.1, nor 010.10.10.1)

This is what I come up with, and it does not work.

r'(^[12]?\d{0,2}\.){3,3}[12]?\d{0,2}'

What am I doing wrong?
Any common knowledge IP matching RE?

Thanks,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070919/ee92d259/attachment.html>


More information about the Python-list mailing list