regular expression back references

Andrew Dalke adalke at mindspring.com
Fri Aug 8 22:40:27 EDT 2003


Clay Shirky
>     # use regexes to see what to split on
>     if re.search(":", new_address):

or use
    if ":" in new_address:

>     elif re.search("-", new_address):
>         new_list = new_address.split("-")
>     elif re.search(".", new_address):
>         new_list = new_address.split(".")

and include a
    else:
        raise Exception("I have no idea what you're asking for")

and maybe some ValueError catching in the int call.

                    Andrew






More information about the Python-list mailing list