Get matching substring groups

Web Site  Methods

 
RegexpMatch::GetCount
 
int GetCount() const
Requires regular expression support to be enabled by defining STR_USE_REGEX 

This method will return the number of groups defined in the regular expression for which a search was performed. For an explanation of expression groups, see the symbols { and } in the overview.

The method should be called only after a successful call to Regexp::Match

 

 
RegexpMatch::GetMatch
 
Str GetMatch(int index)
Requires regular expression support to be enabled by defining STR_USE_REGEX 

This method can be called after a successful regular expression search was completed (see Regexp::Match) and if the regular expression contained valid groups. The index parameter identifies the group for which info must be retrieved. index must be between 0 and GetCount()-1

GetMatch will return the substring that matches the particular regular expression group.  To return the entire matching substring, GetCompleteMatch.

A source code example can be found in the overview.

 

 
RegexpMatch::GetMatch
 
void GetMatch(int index, const STRCHAR **start, const STRCHAR **end)
Requires regular expression support to be enabled by defining STR_USE_REGEX 

This form of GetMatch operates like the previous one, but instead of returning a string object, it will store a pointer to the beginning of the matching substring in start, and to the first character after the end of the matching substring in end

By subtracting the original string pointer from start and/or end, the caller can identify the character offsets of the matching substring.

 

See also: Regular expression classes, Regular expressions overview