splitting perl-style find/replace regexp using python

Peter Otten __peter__ at web.de
Thu Mar 1 12:10:09 CET 2007

John Pye wrote:

> Is there an easy and general way that I can split these perl-style
> find-and-replace expressions into something I can use with Python, eg
> re.sub('search','replace',str) ?

Another candidate:

>>> re.compile(r"(?:/((?:\\.|[^/])*))").findall(r"/abc\\/def\/ghi//jkl")
['abc\\\\', 'def\\/ghi', '', 'jkl']


More information about the Python-list mailing list