regex
Syntax: %regex(s,regular-expression,var1,var2,...varN,varN+1)
Related: #REGEX, %subregex, %match
test to see if string s matches the given Regular Expression. 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 %regex. You can use a local variable name instead of a normal variable - %regex will implicitly declare the local variables before giving them values.
Examples:
#SHOW %regex("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 %regex("Zugg says Hi","(\w+) says (.+)",$Name,$Message,$X)
Same as the above but with local variables. |