Regex help

David A McInnis david at dataovation.com
Sat Dec 8 00:04:46 CET 2001


Is there a more efficient way to do this.  It seams like this is executing
the search twice.

    patt = re.compile("fax<br>\s*([0-9]{3,3}-[0-9]{3,3}-[0-9]{4,4})", re.I)
    if patt.search(tststring):
        faxnum = patt.search(tststring).group(1)
        print faxnum

I cannot just do
    faxnum = patt.search(tststring).group(1)

because if there is no match, it returns an error

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20011207/23407979/attachment.html>


More information about the Python-list mailing list