• C++ Boost::Regex Usage


    In Boost library, there are totally three libraries to support regex parser, regex, xpressive and ..

    the xpressive library is static compile, that means it will cause a lot of time to build your project even if you just change small piece of code.

    Regex usage

    static boost::regex rex("<a[^>]*?href=\"(.[^>]*)(?=\")", boost::regex::icase);

    boost::cmatch what;
    boost::match_flag_type flags = boost::match_default;

    string ss(psz);
    boost::sregex_iterator itBgn(ss.begin(), ss.end(), rex);
    boost::sregex_iterator itEnd;
    for_each(itBgn, itEnd, [&urls](const boost::match_results<std::string::const_iterator>& what){
    //cout<<what.str()<<endl;// 0 for whole match 1 for the first group
    if (what.size() - 1 > 0)
    urls.push_back(what[1].str());
    });

    the first match group is start index is 1. 0 is for the whole match for the regex syntax.

  • 相关阅读:
    systemd管理服务
    卷积神经网络
    matplotlib-3.2.1
    pandas-1.0.3
    numpy-1.18.4
    降维
    无监督学习-聚类
    集成学习
    人工神经网络
    贝叶斯分类
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2965508.html
Copyright © 2020-2023  润新知