The ATL is encapsulated once, so you do not need to write tedious calls every time.
Bool matchRegExp (const CString & strTag, const CString & strPattern, std: vector <CString> & rer)
...{
Rer. clear ();
Bool bRet = false;
ATL: CAtlRegExp <> regex;
ATL: REParseError status = regex. Parse (strPattern );
If (REPARSE_ERROR_ OK = status)
...{
CAtlREMatchContext <> mc;
Const CAtlRegExp <>:: RECHAR * pCon = strTag;
Std: vector <CString> record;
While (RegEx. Match (pcon, & Mc, & pcon ))
...{
Record. Clear ();
Record. Reserve (MC. m_unumgroups );
For (uint ngroupindex = 0; ngroupindex <MC. m_unumgroups;
++ Ngroupindex)
...{
Const catlrematchcontext <>:: RECHAR * szstart = 0;
Const CAtlREMatchContext <>:: RECHAR * szEnd = 0;
Mc. GetMatch (nGroupIndex, & szStart, & szEnd );
Ptrdiff_t nLength = szEnd-szStart;
TCHAR * strMatch = new TCHAR [nLength + 1];
StrMatch [nLength] = 0;
_ Tcsncpy (strMatch, szStart, nLength );
Record. push_back (strMatch );
Delete [] strMatch;
}
Rer. push_back (record );
If (pCon-strTag> = strTag. GetLength () // seems there is a bug in catlregexp library, I have to check this by myself.
Break;
}
}
Return RER. Size ()! = 0;
}