$regex: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
m added null page
 
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''$regex([name], text, re)'''
Returns N, the number of strings in text that matched the regular expression.<br />
You can assign a name to a $regex() call which you can use later in [[$regml|$regml()]] to reference a match list.<br />
If you don't specify a name, all identifiers use a default name which is overwritten with each call to $regex().<br />
$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
[[Category:Regular_Expression]]
[[Category:Regular_Expression]]
[[Category:Identifiers]]

Latest revision as of 23:16, 2 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