I'm trying to replace words in a string
using C#. Every time, I would like to get one matched word replaced.
Example:
"This is example 1, this is example 2, that is example 3."
Let's replace "is"
with "###"
one by one, then we should get 3 strings:
Desired outcome:
"This ### example 1, this is example 2, that is example 3."
"This is example 1, this ### example 2, that is example 3."
"This is example 1, this is example 2, that ### example 3."
===== update =====
I'm new to Stack Overflow and thanks all for helping!
I was searching for match collection but didn't know how to replace word from a certain index (word matched index), so I ask this question. Thanks Dmitry for Linq solution and modifying the description of this question! Also thanks Anu for your solution!