On Sat, Sep 29, 2007 at 12:05:26PM -0700, thebjorn wrote:
> Ok, if you want a single RE... How about:
>...
>   r = re.compile(r'''
>       (?:href=['"][^#]+[#]([^"']+)["'])
>     | (?:name=['"]?([^'">]+))
>   ''', re.IGNORECASE | re.MULTILINE | re.DOTALL | re.VERBOSE)

maybe a little bit easier to read with ungreedy operators:

r = re.compile(r'''
       (?:href=['"].+?[#](.+?)["'])
     | (?:name=['"]?(.+?)['">]))
''', re.IGNORECASE | re.MULTILINE | re.DOTALL | re.VERBOSE)

flo.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to