Method RegEx():getMatchText() Foundation

Gets the matched text from a match result.

Syntax
:getMatchText( <aMatch>, [<nGroup>] ) --> cString
Parameters
<aMatch>
An array with match results as returned by :match() or :matchAll().
<nGroup>
The index of the capture group to process. A value of 0 corresponds to the so-called full match. A value of 1 indicates the first capture group, 2 the second capture group and so on. The default value is 0.
Return

A string with the matched text, or the empty string ("") no match was found.

Description

Helper class method to safely extract the matched text from a match result array. Handles array bounds checking and type validation.

Get match text

aMatch := oRegEx:match("Name: John") 
? RegEx():getMatchText(aMatch)     // Full match 
? RegEx():getMatchText(aMatch, 1)  // First capture group 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.