Skip to main content
ATL Server Library Reference 
CAtlREMatchContext Class 

This class represents a match context.

template <
   class CharTraits = CAtlRECharTraits
class CAtlREMatchContext



A character traits object. See, for instance, CAtlRECharTraitsA.

This class is used in conjunction with CAtlRegExp.

A CAtlREMatchContext object contains information about the "match groups" in a regular expression. Match groups are indicated by braces, and allow you to extract the actual text that matches the regular expression. For example, this regular expression has two match groups:


This regular expression would match input such as "100-1234", and the two match groups would be "100" and "1234", respectively.

A CAtlREMatchContext object is passed in the call to CAtlRegExp::Match:

CAtlRegExp<> re;                 // regular expression object
re.Parse( "{[0-9]+}-{[0-9]+}" ); // set up regular expression
CAtlREMatchContext<> mc;         // match context object
re.Match( "100-1234", &mc );     // 2nd argument is match context

After the call to Match, data member m_uNumGroups contains the number of match groups (in this case, 2) and calling GetMatch returns pointers to the beginning and end of each match group in the input:

MatchGroups graphic

The pointers point into the original input string and thus are only valid during the lifetime of the input string.

See the example in CAtlRegExp.

Header: atlrx.h