tglogo.png
0 LIKES

Snippet


$replaceTok(string,substr,n,token) by Imk0tter

In Category General IRC Posted by Snippets On 12/04/23

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

Example: $replaceTok(this @ is @ a @ test, @, -1, --) = this @ is @ a -- test
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)))
}


Comments 0


Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand