I have a string like
'John is a student. He is also a researcher. He is also a human.'
I have start and end indexes of John and first He. Is there a way to replace these substrings simultaneously with x. Note that I should not replace second He because I have indexes only for the first He.
We can obviously iterate over string, copy whenever the pointer is not in the window of substring and putting x instead. But, is there a better way than this?
Also, note that indexes are non-overlapping.
Johnfirst. Then the indexes ofHeno longer representHe. So, "simultaneously".