Skip to content
TG007 community snippet #109

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

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

By Snippets Added Dec 4, 2023
General IRC All snippets
mIRC script 4 lines
About this snippet

Overview

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
Source code

mIRC script

4 lines · 178 characters
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)))
}
Community

Comments

Want to join the discussion? Sign in to TG007.
No comments yet. Start the discussion.