正则表达式之 deelx.h

先下载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();
}

 

posted @ 2010-08-23 13:16  zhouli  阅读(681)  评论(0编辑  收藏  举报