How to use python regular expression to substitute string value

Allerdyce.John at gmail.com Allerdyce.John at gmail.com
Sun Feb 26 14:43:09 EST 2006


When I try your idea, I have this error

    x, y, width, height = re.findall(pattern, str)[0]
IndexError: list index out of range

How can I use findall to handle error case? i.e. what if there is no
match? how can I handle it gracefully?




More information about the Python-list mailing list