Method RegEx():getGroupCount() Foundation

Gets the number of capture groups in a match result.

Syntax
:getGroupCount( <aMatch> ) --> nCount
Parameters
<aMatch>
An array with match results as returned by :match() or :matchAll().
Return

The number of capture groups.

Description

Helper class method that counts the number of capture groups in a match result array. The count excludes the full match (group 0).

Get group count

oRegEx := RegEx():create("(\d{4})-(\d{2})-(\d{2})") 
aMatch := oRegEx:match("2023-12-25") 
oRegEx:destroy() 

? RegEx():getGroupCount(aMatch)  // 3 

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.