I\'m trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have
function pipe_replace(str,n) {
m = 0;
return str.replace(/\|\|/g, function (x) {
//was n++ should have been m++
m++;
if (n==m) {
return "&&";
} else {
return x;
}
});
}