Program inefficiency?
Florian Schmidt
schmidt_florian at gmx.de
Mon Oct 1 12:48:04 EDT 2007
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.
More information about the Python-list
mailing list