$reptok_(text,token,new,N).cs/mcs/m

By DarthReven on Apr 04, 2005

This alias will uses all of $reptok's built in features and adds in the option to replace all instances of a token within a line of text.

;Uses
;$reptok_(text,token,new,N) (Works the same as $reptok)
;$reptok_(text,token,new,N).cs (Uses $reptokcs to process the replacement)
;$reptok_(text,token,new,N).mcs (Replaces multipule insances of a token within a line of text that are case-sensitive)
;$reptok_(text,token,new,N).m (Replaces multipule insances of a token within a line of text that are not case-sensitive)
alias reptok_ {
  if ($prop) {
    if ($regex($prop,/(mcs|cs|m)/)) {
      if ($regml(1) == cs) { return $reptokcs($1,$2,$3,$4) }
      elseif ($regml(1) == m) {
        var %t $1,%k $2,%r $3,%x $4,%f $findtok($1,$2,0,$4)
        while (%f) {
          %t = $reptok(%t,%k,%r,%f,%x)
          dec %f
        }
        return %t
      }
      else {
        var %t $1,%k $2,%r $3,%x $4,%f $findtok($1,$2,0,$4)
        while (%f) {
          %t = $reptokcs(%t,%k,%r,%f,%x)
          dec %f
        }
        return %t
      }
    }
    else { beep 2 | echo $color(ctcp) -a ERROR - $upper($prop) is not a valid property of $reptok }
  }
  else { return $reptok($1,$2,$3,$4) }
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.