程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> c++-C++使用正則表達式出現錯誤

c++-C++使用正則表達式出現錯誤

編輯:編程綜合問答
C++使用正則表達式出現錯誤

我要提取這個:20110604-092737<\INFO :0xb7f2a6d0>

但是代碼總是出現如下錯誤:
圖片說明

代碼如下:

#include <string>
#include <iostream>
#include <regex>
#include <stdio.h>

int main()
{
    std::string str = "20110604-092737<INFO :0xb7f2a6d0>: Player logout: 忘了愛過誰";
    std::regex rgx("^[\\d\\-\\d\\<\\w\\s{0,1}\\:\\w>]");
    std::smatch result;
    if (std::regex_search(str, result, rgx))
    {
        std::cout << result.str();
    }

}

最佳回答:


在vc2010下運行通過,這個更簡潔:

    std::regex rgx("^\\d*-\\d*<\\w*\\s{0,1}:\\w*>");

qq_27183003
caozhy
caozhy
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved