正则表达式之 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();
}

 

转载于:https://www.cnblogs.com/pbreak/archive/2010/08/23/1806357.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
options: -s single-line mode -m multi-line mode -i ignoreCase -G global -R from right to left -E extended-regexp pattern ERE -e ="PAT-regexp" -C ="strToOperate" -F fixed-strings fgrep -c ="num" print only a count of matching first lines per file -n force the prefixing filename on output -N without prefixing filename on output -o show only the part of the line that matched -f ="file" read regex patterns from file -q quiet suppress all normal output,stderr etc -O output file offsets, not text -x print line number with output lines -r recursively scan sub-directories -I select only non-matching lines -S ="replaceto" Match(regexp)-->replaceto -p ="bak-suffix-name",Modify file(S) directly,will create backup file(s) if bak- suffix-name is not null -d ="dir to search" default=currentDirectory,dir-str can't end with \",avoid esc ape " -X mask filename to be operated with regex -T only output filename and match num for per file search file:if set the -e arg and no (-C arg || stdin-pipe || inputfile),then ou tput filepath that match -ergx;if -o arg is set,output filenames only 从命令行中-C参数指定要处理的字符串: C:\>E:\MyProjects1117\deelxGrepSed\Debug\deelxgrep.exe -Chello2012 -e2\d+2 Line:1 Offset:5 hello2012 //output -o参数指定只输出匹配部分: C:\>E:\MyProjects1117\deelxGrepSed\Debug\deelxgrep.exe -Chello2012 -e2\d+2 -o 2012 从标准输入 管道里获取要处理的数据 C:\>help |E:\MyProjects1117\deelxGrepSed\Debug\deelxgrep.exe -e^V.+?\s -o VERT VE VER VER VERIFY VOL 从文件里读取数据处理,支持递归处理目录 E:\MyProjects1117\deelxGrepSed\Release>deelxgrep.exe -ewindows Boo-t.ini -i Boo-t.ini result : Line:3 Offset:45 (0)partition(1)\WINDOWS [operating sys Line:5 Offset:37 (0)partition(1)\WINDOWS="Microsoft Wind Line:5 Offset:56 DOWS="Microsoft Windows XP Professional -d指定目录,-r表示递归处理 -e指定要查找的表达式,如果没有带处理数据(即没有-C\管道输入\指定文件)但指定了目录,则会 处理目录下的目录名和文件名,并输出符合表达式的路径名称 E:\MyProjects1117\deelxGrepSed\Release>deelxgrep.exe -eboot.i*i -i -d"c:" -r c:\boot.ini E:\MyProjects1117\deelxGrepSed\Release>deelxgrep.exe -eboot.i*i -i -d"c:\\"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值