Top index Wirbel home

::match

string.match(string) - match string against regular expression, extract groups

string.match(string) matches the string agains an extended regular expression. If the expression matches, a list of string is returned: the list of matched groups. The first element in the list is the whole match. If the string does not match the expression then null is returned. If you do not need extraction of groups you can also use the operator =~, which matches a string against a regex.

Examples

 "svn/wirbel/baustones".match("(.*)/(.*)/(.*)") == ["svn/wirbel/baustones", "svn", "wirbel", "baustones"]
 "hirn".match("sepp") == null
Matching with =~:
 ("Super" =~ "S.*r") == true