Regex GroupVal() Method

After calling Matches(), if the regex pattern used parenthesis to denote grouping, this returns the group specified.

Function Signature

 string GroupVal( int group )

Parameters

Parameter Type Description

group

int

Value 0 will return the full text matched by the regex; groups 1-n (see Regex GroupCount() Method) will return the groupings that the regex pattern identified using parentheses.

Return

Type Description

string

The specified group.

Technical Details

SBM ModScript version: 11.3.

Example

var r = Regex();
r.Compile("(\\d+)[^\\d]*(\\d+)");
r.Matches("12ab3d456e78");
for ( var i = 0; i < r.GroupCount(); ++i ) {
	Ext.WriteStream( r.GroupVal(i) ); 
} 

Result:

12ab3
12
3 

Notes

None.

Related Topics

Regex