Closed GoogleCodeExporter closed 9 years ago
I don't think that there's sufficient demand for it. Anyway, it can be
shortened:
def search_and_replace(string,
search_regex, search_flags,
replace_regex, replace_flags,
replace_string):
'''two steps: 1, search. 2, replace the first step's results.'''
def replacement(match):
return re.sub(replace_regex, replace_string, match.group(), flags=replace_flags)
return re.sub(search_regex, replacement, string, flags=search_flags)
Original comment by re...@mrabarnett.plus.com
on 21 May 2014 at 2:12
Original issue reported on code.google.com by
animaliz...@gmail.com
on 21 May 2014 at 1:11