Selectively replace multiple instances of a character within a string: Difference between revisions
Selectively replace multiple instances of a character within a string (view source)
Revision as of 19:51, 28 July 2022
, 1 year ago→Python
m (→Python) |
|||
Line 574:
def nthInstanceReplaced(ruleMap):
def go(a, c):
if c in
return (
dict(a, **{c: ds[1
) if ds else (a, c)
else:
return a, c
return lambda s: ''.join(
mapAccumL(go)(
)
|