c++11新特性正则匹配

下面是示例

复制代码
#include <iostream>
#include <string>
#include <fstream>
#include <regex>
int main()
{
    std::ifstream file("d:/xudp.html");
    std::istreambuf_iterator<char> begin(file), end;
    std::string str(begin, end);

    std::regex reg("<a [^>]*>");
    std::smatch m;
    for (auto cur = std::sregex_iterator(str.begin(), str.end(), reg);cur != std::sregex_iterator();++cur)
    {
            std::cout<<(*cur).str()<<std::endl;
    }
    std::cin.get();
    return 0;
}
复制代码

 

posted @ 2022-01-01 13:44  浪迹天涯的程序员  阅读(45)  评论(0)    收藏  举报
相关博文:
阅读排行:
· 从被喷“假开源”到登顶 GitHub 热榜,这个开源项目上演王者归来!
· Stack Overflow,轰然倒下!
· Cursor 1.2重磅更新,这个痛点终于被解决了!
· 上周热点回顾(6.30-7.6)
· .NET AI 模板
点击右上角即可分享
微信分享提示