Regexp使用示例(C++代码)
2012-02-21 15:18
225 查看
1 判断一个字符串是否为ip地址:
待续....
附录——规则表达式规则
Regexp reg("^[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}$"); String ip="192.168.1.222"; bool match=false; match = ip.matches(reg); // true
待续....
附录——规则表达式规则
; Minimalistic basic regular expressions information ; ^ matches start of string ; $ matches end of string ; . matches any character ; [list] matches one character in the list ; [^list] matches one character not in list ; Lists can be individual characters or ranges char-char. You can insert ] ; by making it the first character in list and ^ by making it not the first ; character ; * matches preceeding expression any number of times (including zero) ; \+ matches preceeding expression at least one time ; \? matches preceeding expression zero or one time ; \{N\} matches preceeding expression exactly N times ; \{N,\} matches preceeding expression N or more times ; \{N,M\} matches preceeding expression between N and M times ; \( \) captures the contained subexpression ; Remember matches are greedy, they will match as much as possible ; You must escape ^ $ . * [ and \ with \ whenever you want them to be normal ; characters except in lists ; Please see the manual pages for grep and sed for more information
相关文章推荐
- 从零开始学C++之STL(七):剩下5种算法代码分析与使用示例(remove 、rotate 、sort、lower_bound、accumulate)
- C++之STL(七):剩下5种算法代码分析与使用示例(remove 、rotate 、sort、lower_bound、accumulate)
- 从零开始学C++之STL(七):剩下5种算法代码分析与使用示例(remove 、rotate 、sort、lower_bound、accumulate)
- Cocos2d-x使用Javascript开发js绑定C++<代码示例>
- 从零开始学C++之STL(七):剩下5种算法代码分析与使用示例(remove 、rotate 、sort、lower_bound、accumulate)
- 在C++中使用sqlite的示例(从下载、编译、工程建立、配置、测试代码编写全方位介绍)
- C++ Map的基本使用(代码示例)
- Ruby使用C++扩展实例(含C++扩展代码示例)
- 在C++中使用sqlite的示例(从下载、编译、工程建立、配置、测试代码编写全方位介绍)
- 从零开始学C++之STL(七):剩下5种算法代码分析与使用示例(remove 、rotate 、sort、lower_bound、accumulate)
- C++统计软件使用时间代码示例
- linux c/c++ 聊天小程序代码示例 (使用socket 和 IO 多路复用技术)
- Python编程使用tkinter模块实现计算器软件完整代码示例
- 使用Python的Twisted框架编写非阻塞程序的代码示例
- Spark的广播变量和累加器使用方法代码示例
- 在Vue 中使用Typescript的示例代码
- C++使用Mysql的详细步骤及各个常用方法的代码演示:select,insert,update,delete
- C++中文件流(fstream)的使用方法及示例
- C#使用互斥量(Mutex)实现多进程并发操作时多进程间线程同步操作(进程同步)的简单示例代码及使用方法
- 在C/C++代码中使用SSE等指令集的指令(4)SSE指令集Intrinsic函数使用