VS2015 C ++正则表达式迭代器堆栈溢出

时间:2017-11-03 03:35:43

标签: c++ regex visual-studio-2015

我在Visual Studio 2015中使用C ++正则表达式时遇到问题,之前我的代码运行正常,使用CodeBlocks(gcc C ++ 11)

这里我剪切了我的代码,只是正则表达式问题部分:

#include <iostream>
#include <regex>

using namespace std;

int main()
{
    string s="Cart #447\n148112058058118118,14810c112148112043109016118,148112019,04c14804c01300d,05810618104c0160c401c18104c148118,00d10610905211805810618104c016,019118112019112106109013016,01310914810c1120c414810c04c052046,04610904310914204c,052109106046043118190\nCart #224\n04600718110904610c,04c14804c01300d,148109013019190,01610900718104c016112046,11210611800d109013112,14811201601610900d1180c414810c118118046118,04910901301908510904c019046,01611204c0431180160c4052109052118106,11204c043,0461c01121060190c405804c04610c,14810c04c04304c,1061121090460160c4049118118058,14810611204c046046109013016046,14210914810910611201304c,046112181052,112109016142118109043,016106118109016046,103181142007181109016046,04910611810901610c0c414204c013016046,043112049046016118106,04c0130460161090130160c4013112112019043118046,0461121900c4046109181148118,04605204c01310914810c,05810618104c0160c401c18104c148118,0460161181091030c4046109181148118\nCart #406\n112109016142118109043,14810c1181180d004c118046,046148106181049049118106046,00d181142,0431091810130191061900c401911801611810600d118013016,04618100d109106,14810c04c1481030c4052118109046,1090520520431180c4046109181148118,04318101314810c0c404910900d046,11204c043,04904311810914810c,0461090431090190c401910611804604604c01300d\nCart #773\n0461121900c4046109181148118,04610c10611801901904c118046,1c010c04c05205204c01300d0c4148106118109142,14810c04c04304c,05210905210604c103109,19011200d181106016,14204c01304c0c41c010c118109016046,190109142046,14811211210304c118046,04605204c01310914810c\nCart #590\n0521121061030c414810c112052046,14810918104304c0580431121c0118106,04601604c1060c4058106190,1421090520431180c4046190106181052,0521810580581180190c41c010c118109016,00d1061090131120431090c4049109106046,14811201301904c01604c112013118106,1480431120c1118046,11201304c112013046,148106118109142,016181106103118190,14218105805804c0130c414204c091,046109043046109,01310905210304c013046,05211805205211810611201304c,0161090161181060c4016112016046,14810c04c04304c,14210919011201301310904c046118\nCart #621\n148106118109142,112190046016118106046,04910900d181118016016118,0c110901304c0430431090c4118091016106109148016,01911200d0c4058112112019,0d018114814810c04c01304c,05211814801604c013,0161091060161091060c4046109181148118,14811211210304c118046,04910611810901610c0c414204c013016046,0461181090581121120190c40581061120d01180130c4,049118109013046,14810904904910900d118,10604c148118,1481120160161120130c40461c0109049046,04605204c01310914810c,10311210c04310610904904c,04605211201300d118046,10901301610914804c019046,0491061181090190c4148106181142049046,14810918104304c0580431121c0118106,14218104610c106112112142046\n";

    regex cregex("Cart [#]([0-9]+)[\\n]((([0-9a-fA-F]{3})+[,])+([0-9a-fA-F]{3})+)[\\n]");

    sregex_iterator i(s.begin(), s.end(), cregex);

    while(i!=sregex_iterator())
    {
        cout << i->str() << endl;
        i++;
    }

    system("pause");


    return 0;
}

它一直给我堆栈溢出错误

  

TestRegex.exe中0x003EC447处的未处理异常:0xC00000FD:堆栈   溢出(参数:0x00000001,0x00E02FDC)。

同样在codeblocks中,我可以使用这种正则表达式格式,但是当我转移到visual studio时它只是不起作用:

regex cregex("Cart #([0-9]+)\n(([0-9a-fA-F]{3}+,)+[0-9a-fA-F]{3}+)\n");

关闭了与其他问题相同的问题,但是当我打开时,问题基本上没什么,我不确定,在我的情况下,正则表达式正在与其他编译器合作,它&#39 ;当我搬到visual studio遇到这个问题的时候:|

0 个答案:

没有答案