Locate and substitute the 3rd instance of each character in a given string with H
For example: 74Mercedes1980 would become 74HerHedHs1H80
This task can be accomplished using C# or regex.
I have come across a Javascript script that achieves this, but I am looking to translate it into C#. Can you provide assistance?
Source found at here
str = str.replace(/((?:[^x]*x){2}[^x]*)x/g, '$1y');
let str = 'I amx nexver axt hoxme on Sxundxaxs';
let n = 3;
let ch = 'x';
let regex = new RegExp("((?:[^" +ch+ "]*" +ch+ "){" + (n-1) + "}[^" +ch+ "]*)" +ch, "g");
str = str.replace(regex, '$1y');
console.log(str);
//=> I amx nexver ayt hoxme on Sxundyaxs