摘要: http://dozb.bokee.com/1976532.html模板类:lbasic_regex 用来保存一个“正则表达式”的类。lsub_match 继承于pair<Iterator,Iterator>迭代器组,用来表示匹配的一个结果。lmatch_results sub_match的容器,用来表示一次搜索或匹配算法的所有结果,类似于vector<sub_match>。算法:lregex_math匹配算法,测试一个字符串是否和一个正则式匹配,并通过match_results返回结果。lregex_find 查找算法,查找字符串的一个和正则式匹配的字串,并通过mat 阅读全文
posted @ 2012-10-11 17:25 瑞尼书苑 阅读(642) 评论(0) 推荐(0)
摘要: C++ 使用正则表达式分割字符串#include <iostream>#include <string>#include <boost/regex.hpp>int main(){ std::string s = "who,lives:in-a,pineapple under the sea?"; boost::regex re(",|:|-|\\s+"); boost::sregex_token_iterator p(s.begin(),s.end(),re,-1); boost::sregex_token_itera 阅读全文
posted @ 2012-10-11 17:19 瑞尼书苑 阅读(4211) 评论(0) 推荐(0)
摘要: 为了能够让用户更清晰的写采集规则,特意把采集回来的源码经过精简之后再进行处理,比如,要删除 <style> </style> <script> </script>注释等内容去除标签垃圾属性等,使用正则表达式,大一点的网页数据,匹配替换为空一次竟然可以达到几百毫秒,吓死人,故自己写了个函数,同样的数据大小1-3毫秒完成.Cpp代码<span><spanstyle="color:#000000;">//------这上面几段垃圾html代码删不掉了,请无视它,自动跑进去的classBaseLib{publi 阅读全文
posted @ 2012-10-11 16:40 瑞尼书苑 阅读(837) 评论(0) 推荐(0)