regexp substitution - a lot of work!
fredrik at pythonware.com
Fri Jun 18 19:05:39 CEST 2004
Lukas Holcik quoted someone writing:
> > I don't understand your point. The Python equivalent is:
> > re.sub('(..)', r'x\1x', s)
> > or using a precompiled pattern:
> > pat.sub(r'x\1x', s)
footnote: you can use a callback instead of the replacement pattern.
callbacks are often faster, and can lead more readable code:
(as the other examples on that page show, you can do a lot of weird
stuff with re.sub callbacks...)
More information about the Python-list