Simple identifier to return all matched tokens in a string separated by a common character.
;;---- $matchedtok : brinxy ----;;
;; About ;;
;; $matchedtok compiles a list of tokens based on matches in a string. ;;
;; You can manipulate this list by using properties to be used like $1 or $2 or $gettok(<string>,N,C) ;;
;; -----------------------------------;;
;; Snippet syntax ;;
;; ------------------------------;;
;; $matchedtok(string,searched token,C)[.prop] ;;
;; To break it down ;;
;; - string: The string to search for the token..
;; - searched token: input to be searched in the string
;; - C: Common separator
;; - [.prop] Similar to $1 and $2 just for the separated tokens. *must be a number*
;; -------------------------------;;
;; Examples: ;;
;; $matchedtok(this is a string of text,s,32) - returns: "this is string" because those all are tokens with 's' in them.
;; $matchedtok(this is a string of text,s,32).1 would return "this" because that is the first match.
;; Counter Examples ;;
;; $matchedtok(this is a string of text,s,32).234 returns $false because there is no 234th token. Remember that the property MUST be the Nth token IN the text.
;; $matchedtok(this is a string of text,s,32).a returns $false because the property is not a number.
;; $matchedtok(this is a string of test,s,32).3- returns $false because there are no tokens beyond the third.
;; ------------------------------------;;
alias matchedtok {
if ($$1 && $2-3 && $isid) {
var %t = $$1, %o
while ($findtok(%t,$wildtok(%t,$+(*,$2,*),1,$3),$3)) {
%o = $addtok(%o, $gettok(%t,$ifmatch,$3),$3)
%t = $deltok(%t,$ifmatch,$3)
}
return $iif($prop,$iif($regex($prop,/^([0-9]+)|[-]/gi) && $prop !> $numtok(%o,$3),$gettok(%o,$prop,$3),$false),$iif(%o,%o,$false))
}
}
Thanks xDaeMoN. But I do believe that mIRC\'s built-in $matchtok will only return one token. Meaning if I used: $matchtok(this is a string,s,1-,32) would only return this. (That\'s what I got when I tested it.) On the contrary, my snippet uses $gettok when retrieving data so you can use things such as 1-. I guess this is just an enhancement to $matchtok.