Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CAtlREMatchContext Class 

This class represents a match context.


template <
   class CharTraits = CAtlRECharTraits
>
class CAtlREMatchContext

Parameters

CharTraits

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:

{[0-9]+}-{[0-9]+}

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
NoteNote

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft