matches: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Added version.)
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 6: Line 6:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
matches(str, pattern)
matches(str, pattern)
</source>
</syntaxhighlight>


|examples=
|examples=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
     [r: matches("This is a test", "test")]
     [r: matches("This is a test", "test")]
     [r: matches("test", "test")]
     [r: matches("test", "test")]
     [r: matches("This is a test", ".*test")]
     [r: matches("This is a test", ".*test")]


</source>
</syntaxhighlight>
Returns  
Returns  
<pre>
     0
     0
     1
     1
     1
     1
</pre>
}}
}}
[[Category:String Function]]
[[Category:String Function]]

Latest revision as of 23:59, 15 March 2023

matches() Function

Introduced in version 1.3b48
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

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