matches: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Macros:Functions:matches moved to matches: Moved out of Macros namespace)
m (Added MacroFunction template and String Function category)
Line 1: Line 1:
==Function matches==
{{MacroFunction
|name=matches
|description=
Returns 1 if a string matches pattern or 0 if it does not. The pattern can be a [[Macros:regular expression|regular expression]]. Matches performs a while string comparison, so the pattern must match the whole of the input string and not only part of it.
Returns 1 if a string matches pattern or 0 if it does not. The pattern can be a [[Macros:regular expression|regular expression]]. Matches performs a while string comparison, so the pattern must match the whole of the input string and not only part of it.


===Usage===
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: val = matches(str, pattern)]
[h: val = matches(str, pattern)]
</source>
</source>


 
|examples=
 
===Examples===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
     [r: matches("This is a test", "test")]
     [r: matches("This is a test", "test")]
Line 20: Line 20:
     1
     1
     1
     1
}}
[[Category:String Function]]

Revision as of 02:55, 9 March 2009

matches() Function

Returns 1 if a string matches pattern or 0 if it does not. The pattern can be a regular expression. Matches performs a while string comparison, so the pattern must match the whole of the input string and not only part of it.

Usage

[h: val = matches(str, pattern)]

Examples

    [r: matches("This is a test", "test")]
    [r: matches("test", "test")]
    [r: matches("This is a test", ".*test")]

Returns

   0
   1
1