Difference between revisions of "$regex"
From Scriptwiki
m (added stub) |
m (removing stub-pages, added content) |
||
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]] |
Revision as of 09:22, 11 October 2006
$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