Here is an alias that allows you to replace the n'th occurence of the specified substring in the specified string with a token.

IE: $replaceTok(this @ is @ a @ test, @, -1, --) = this @ is @ a -- test

Code
alias replacetok {
  var %pos $pos($1,$2,$iif($3 > 0,$3,$calc($pos($1,$2,0) + $3 + 1)))
  return $+($left($1,$calc(%pos - 1)),$$4,$right($1,- $+ $calc(%pos + $len($2) - 1)))
}


Feel free to fork/optimize the code!