先下载deelx.h文件/Files/pbreak/deelx.zip
举个简单的例子:
#include "deelx.h" //包含头文件
BOOL CContrlPane::IPCheck(CString ipAddress)
{
// 25[0-5] (250 - 255)
// 2[0-4]\\d (200 - 249)
// [0-1]\\d{2} (000 - 199)
// [1-9]?\\d (1 - 99)
CString num = _T("(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)");
CRegexpT <char> regexp("^"+ num + "\\." + num + "\\." + num + "\\." + num + "$");
MatchResult result = regexp.MatchExact(ipAddress);
return result.IsMatched();
}