$regex

From Scriptwiki
Revision as of 00:16, 3 February 2011 by Vliedel (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

$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