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  浪迹天涯的程序员  阅读(46)  评论(0)    收藏  举报
点击右上角即可分享
微信分享提示