将ATL进行了一次封装,不用每次都写繁琐的调用 bool matchRegExp(const CString& strTag, const CString& strPattern,std::vector<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;}