Function: match

Function: match

Usage

 match(some_string, match: regular expression)

Does a string match the given regular expression?

When the match is performed many times with the same regular expression it is more efficient to declare that as a default argument:

 my_match := match@(match: "something")
 my_match("input") # called many times

This way the regular expression is only compiled once.

Parameters

Parameter Type Description
input string String to match.
match regex Regular expression to match.

Examples

 match("aaaa", match:"a*")   == true
 match("a",    match:"b*")   == true
 match("abc",  match:"b+")   == true
 match("abc",  match:"$b+^") == false

 f := match@(match: "a+|b+")
 f("xyz")  == false
 f("aabb") == true

See also

contains Does a string contain another one?