paparika

求助一个简单的 c++正则

  •  
  •   paparika · Sep 3, 2018 · 3706 views
    This topic created in 2827 days ago, the information mentioned may be changed or developed.

    假设有这样一个串,"fsdfsda13124tag=cpp;2343dfdadf" 我现在已经可以提取出 tag=cpp;了。试问如何能提取出 cpp 这部分?

    string s = "fsdfsda13124tag=cpp;2343dfdadf";
    
    _test_regex(s, "tag=(.*?);", result);
    
    void _test_regex(string s, string regex, string& result){
    
        std::smatch m;
        std::regex e (regex);
    
        std::regex_search (s, m, e);
        for (auto x=m.begin();x!=m.end();x++){
            result = x->str();
            break;
        }
    
    }
    
    
    paparika
        1
    paparika  
    OP
       Sep 3, 2018
    或者用 sscanf 完成这一步?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   836 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:54 · PVG 04:54 · LAX 13:54 · JFK 16:54
    ♥ Do have faith in what you're doing.