How do I replace word in string except first occurrence using c#
for example
string s= "hello my name is hello my name hello";
replace hello with x
output should be string news = "hello my name is x my name x";
I tried like works fine
string originalStr = "hello my hello ditch hello";
string temp = "hello";
string str = originalStr.Substring(0, originalStr.IndexOf(temp) + temp.Length);
originalStr = str + originalStr.Substring(str.Length).Replace(temp, "x");
can I have Regex expression for above code ?