Hi,
I am trying to write a python func. which can replace nth occurance of any substring present in any string.
For example:
main_string = "badZZZZZZZZZZZZZZZZZZbadZZZZZZZZZZZZZZZZZZZZzbadZZZZZZZZZZZZZZZZZ"
If I wanna replace the 2nd occurance of string "bad" with 'good' i will pass
customreplace(main_string,'bad','good',2)
So the Function should return
badZZZZZZZZZZZZZZZZZZgoodZZZZZZZZZZZZZZZZZZZZzbadZZZZZZZZZZZZZZZZZ
I have tried normal replace()
main_string.replace('bad','good',2)
. But its not what I wanted.
Thanks In Advance,