Result Function


result (expression)


The result function returns a string matched by the last match function. If the value of the expression is 0, result returns the string matched by the entire regular expression. Otherwise, the result function returns the string matched by the n'th \(...\) in the regular expression, where n is the value of expression.

If there was no previous match function, or the last match was not successful, the result function returns an empty string.

The match and result functions are useful in extracting substrings from a string.


The following example extracts an area code from a phone number

if match (phone, "(\([0-9]\{3\}\))[0-9]\{3\}-[0-9]\{4\}")

set area to result (1)