boost regex正则区配 IP 地址
来源:互联网 发布:维塔斯的奉献知乎 编辑:程序博客网 时间:2024/05/21 12:48
#include <boost/regex.hpp>#include <iostream>#include <string>int main(){ std::string text(" 192.168.0.1 abc 10.0.0.255 10.5.1 1.2.3.4a 5.4.3.2 "); const char* pattern = "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; boost::regex ip_regex(pattern); boost::sregex_iterator it(text.begin(), text.end(), ip_regex); boost::sregex_iterator end; for (; it != end; ++it) { std::cout << it->str() << "\n"; // v.push_back(it->str()); or something similar }}
输出:
192.168.0.110.0.0.2555.4.3.2
参考:http://stackoverflow.com/questions/5804453/c-regular-expressions-with-boost-regex
- boost regex正则区配 IP 地址
- boost regex正则区配 IP 地址
- 正则表达式 boost Regex
- boost - regex 正则表达式
- 正则表达式 boost Regex
- boost regex c++正则表达式
- boost库 -- regex正则表达式
- Boost::regex之正则表达式
- Boost.Regex库 正则表达式
- 9.Boost之正则regex
- [boost] regex c++正则表达式
- boost正则式解析MAC地址和IP地址
- boost正则式解析MAC地址和IP地址
- boost用正则表达式验证ip地址合法
- vs 2008 BOOST 正则IP地址与域名
- Boost 正则表达式库regex使用手记
- Boost学习之正则表达式--regex
- Boost学习之正则表达式--regex
- 应届毕业生的Android高薪之路——摘自学员的博客
- classloader相关基础知识
- struts2的运行机制
- ubuntu上装swftools
- 如何在模拟器里的sd卡存放东西
- boost regex正则区配 IP 地址
- 传智播客版android手机斗地主_成都Java培训_传智播客
- android 自旋锁 spin_lock
- 使用stringstream对象简化类型转换
- Func,Action 的介绍及其用法
- 类加载器
- java中读写锁的实现及使用读写锁简单实现缓存系统的实例
- 在c#项目中调用及调试c++写的dll
- Linux下用Apt-get 安装Mysql