Difference between revisions of "$regex"

From Scriptwiki
Jump to: navigation, search
m (removing stub-pages, added content)
m
 
Line 10: Line 10:
 
  ;'cat' and 'dog' are matched, returns 2
 
  ;'cat' and 'dog' are matched, returns 2
 
[[Category:Regular_Expression]]
 
[[Category:Regular_Expression]]
 +
[[Category:Identifiers]]

Latest revision as of 00:16, 3 February 2011

$regex([name], text, re)

Returns N, the number of strings in text that matched the regular expression.
You can assign a name to a $regex() call which you can use later in $regml() to reference a match list.
If you don't specify a name, all identifiers use a default name which is overwritten with each call to $regex().
$regex() remembers the results for the last ten $regex() calls. Each time you do a match with $regex(), and you specify a name, that name's previous results are overwritten with the new results.

Example:

$regex(a cat walked by the dog,/cat|dog/g)
;'cat' and 'dog' are matched, returns 2