3,248
社区成员




#include <atlrx.h>
int _tmain(int argc, _TCHAR* argv[])
{
CString strWeb = _T("http://sina.com.cn");
CAtlRegExp<> reUrl1;
REParseError status = reUrl1.Parse(_T("(http|https)://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?")); //parse不通过,错误为REPARSE_ERROR_BRACKET_EXPECTED,如果换成下面注释的这一行则Parse可以通过,但是match失败
//REParseError status = reUrl1.Parse(_T("(http|https)://([-\\w]+\\.)+[-\\w]+(/[-\\w ./?%&=]*)?"));
if (REPARSE_ERROR_OK != status)
{
// Unexpected error.
return 0;
}
CAtlREMatchContext<> mcUrl1;
if (!reUrl1.Match(strWeb, &mcUrl1))
{
// Unexpected error.
return 0;
}
return 0;
}