Question regarding lists and regex

Ant antroy at gmail.com
Thu Nov 9 10:23:44 EST 2006



On Nov 9, 6:29 am, Prabhu Gurumurthy <pguru... at gmail.com> wrote:
...
> regex: I presume this is rather a dumb question, anyways here it comes! as you
> can see from my program, pattIp = r\d{1,3}\.... etc, is there any other easy way
> to group the reptitions, instead of typing the same regex 4 times.
...
>                    pattIp = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'

pattIp = r"\d{1,3}(\.\d{1,3}){3}"

Is the best you can get using pure regexes (rather than something like
Paul's solution).




More information about the Python-list mailing list