Find and replace every 3rd character occurrence in a given string and replace it with H
I found this Javascript code that does the same thing and would like to convert it into a C# code. Can you please assist ?
Found 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