Regular Expression之CAtlRegExp
来源:互联网 发布:淘宝嘉年华有什么折扣 编辑:程序博客网 时间:2024/06/04 19:32
bool matchRegExp(const CString& strTag, const CString& strPattern, RegExpResults& rer)
{
rer.clear();
bool bRet = false;
CAtlRegExp<> regex;
REParseError status = regex.Parse(strPattern);
if (REPARSE_ERROR_OK == status)
{
CAtlREMatchContext<> mc;
const CAtlRegExp<>::RECHAR* pCon = strTag;
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;
wchar_t *strMatch = new wchar_t[nLength+1];
strMatch[nLength] = 0;
_tcsncpy_s(strMatch, nLength+1, 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;
}
- Regular Expression之CAtlRegExp
- leetcode之Regular Expression Matching
- LeetCode之Regular Expression Matching
- 【Leetcode】之Regular Expression Matching
- regular expression
- Regular Expression
- regular expression
- Regular Expression
- Regular Expression
- regular expression
- Regular Expression
- Regular Expression
- regular expression
- Regular expression
- Regular Expression
- Regular Expression
- regular expression
- Regular expression
- Winnet获取网页HTML内容-Code
- Monitor server hardware. Tools might include Device Manager, the Hardware Troubleshooting Wizard, and appropriate Control Panel
- 公司就是我的“家”(转)
- PB编译原理探讨中......
- 萨苏:对使用原子弹轰炸日本最好的说明
- Regular Expression之CAtlRegExp
- JBuilder 用户的 NetBeans IDE 指南
- Eclipse快捷键指南
- 阿翔编程学-Web Service详细解析及使用方法(全) 包括XFire、Axis
- DB2基本问题总结
- WriteBoard_FR
- ASP.NET 2.0 正式版中无刷新页面的开发
- 第24章 标准模板库介绍
- Spring使用POJO发布RMI