Syntax
match (expression1, expression2)
Description
The match function matches the string value expression1 with the value of expresssion2. The value of expression2 is a regular expression. If the regular expression matches expression1, the match function returns a true value, otherwise it returns a false value.
If the match function returns a true value, you can use the result function to return the substring of expression1 that matched the regular expression.
Table 8-20: Regular Expressions
Pattern Description
c Matches itself (c can be any character except the special characters \ * . [ $).
\ c Matches single special character c (c can be one of the special characters \ * . [ $).
. Matches any single character.
[class] Matches any single character in class. Class is one or more single characters, a range of characters a-b, or a combination.
[^class] Matches any single character not in class. Class is one or more single characters, a range of characters a-b, or a combination.
re* Matches 0 or more occurrences of the single character regular expression re.
re\{m\} Matches exactly m occurrences of the single character regular expression re.
re\{m,\} Matches at least m occurrences of the single character regular expression re.
re\{m,n\} Matches from m through n occurrences of the single character.
\(re\) Matches the regular expression re and saves the string matched by re.
\n Matches the saved string from the n'th \(...\).
^ At the beginning of a regular expression, ^ matches the beginning of expression1.
$ At the end of a regular expression, $ matches the end of expression1.
re re Matches first regular expression followed by the second regular expression.
Examples
match (x,"abc")
Matches the string abc anywhere in x.
match (x,"^abc")
Matches the string abc at the beginning of x.
match (x,"abc$")
Matches the string abc at the end of x.
match (x,"a\\c")
Matches the string a\c anywhere in x.
match (phone, "([0-9]\{3\})[0-9]\{3\}-[0-9]\{4\}")
Matches a phone number in phone.