match
Syntax: %match(s,pattern,var1,var2,...varN,varN+1)
Related: #TRIGGER, %subregex, %regex
test to see if string s matches the given Pattern. If it matches, the position of the match in the string is returned (starting with 1). If it doesn't match, zero is returned. The optional VarN arguments contain the names of variables to store any captured subpatterns (subpatterns surrounded by parenthesis). The additional VarN+1 variable name can be specified to hold the length of the matched pattern.
The ($localvar:wildcard) syntax detailed here won't work in %match. You can use a local variable name instead of a normal variable - %match will implicitly declare the local variables before giving them values.
Examples:
#SHOW %match("Zugg says Hi","(%w) says (*)",Name,Message,X)
displays 1 and sets the @Name variable to "Zugg", the @Message variable to "Hi" and the @X variable to 12.
#SHOW %match("Zugg says hi","(%w) says (*)",$Name,$Message,$X)
The above example using local variables. |