Gadfly and regsub with Python 2.1

Skip Montanaro skip at pobox.com
Fri Nov 2 10:46:33 EST 2001


    jim> Are there any pitfalls. an amateur should be aware of, in modifying
    jim> Gadfly to use the "re" module?

It's pretty straightforward.  You'll find that in most cases regsub.gsub can
simply be replaced with re.sub (modulo any necessary regex syntax changes)
and that regsub.sub can be replaced with re.sub after adding a count
parameter of 1.

I thought there was a regex->re converter script in the source distribution,
but I can't seem to locate it at the moment.  If you can find it, you may
find it useful to convert more complex regular expressions.

Ah, wait a minute... Andrew Kuchling wrote a regex-to-re howto, available at

    http://py-howto.sourceforge.net/regex-to-re/

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list