3,245
社区成员
发帖
与我相关
我的任务
分享
CString strMatch;
m_editMatch.GetWindowText(strMatch);
CAtlRegExp<> reRule;
WCHAR *wt = (WCHAR *)(LPCTSTR)m_strRex;
REParseError status = reRule.Parse("[0-9]+");
CAtlREMatchContext<> mcRule;
wt = (wchar_t *)(LPCTSTR)strMatch;
if (!reRule.Match("123k456m789",&mcRule))
{
AfxMessageBox("没有相匹配字符!");
}
else
{
AfxMessageBox("有相匹配字符!");
for (UINT nGroupIndex = 0; nGroupIndex < mcRule.m_uNumGroups; ++nGroupIndex)
{
const CAtlREMatchContext<>::RECHAR* szEnd = 0;
const CAtlREMatchContext<>::RECHAR* szStart = 0;
mcRule.GetMatch(nGroupIndex, &szStart, &szEnd);
ptrdiff_t nLength = szEnd - szStart;
char str[100] = {0};
memcpy(str, szStart, nLength);
AfxMessageBox(str);
}
}