makeReplacer¶
- emlib.textlib.makeReplacer(conditions)[source]¶
Create a function to replace many subtrings at once
- Parameters:
conditions (
dict
) – a dictionary mapping a string to its replacement- Return type:
Callable
Example:
>>> replacer = makeReplacer({"&":"&", " ":"_", "(":"\(", ")":"\)"}) >>> replacer("foo & (bar)") "foo_&_\(bar\)"