簡體   English   中英

使用regex_search

[英]Using regex_search

我正在嘗試解析一些文本以弄清楚是否是鏈接。 這是我的代碼:

    smatch m;
    regex e("http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+");
    bool match = regex_search(proto->message, m, e);
    if(match == true) {
        chan->Say("Matched link");
    }

我得到的錯誤是:

/main.cpp|26|error: no matching function for call to ‘regex_search(char [1024], boost::smatch&, boost::regex&)’|

當我從regex_search取出m時,它可以工作並返回boolean ,但是我想知道實際匹配的是什么。

Boost的regex_search沒有定義您要使用的簽名。 在任何一個重載都不是boost :: smatch第二個參數。 實際上,根本不使用匹配。 請參閱文檔 ,尤其是頁面底部的示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM