VS2015 C++ regex iterator stack overflow

1

I have problem using C++ regex in visual studio 2015, previously i my code is running ok using CodeBlocks (gcc C++11)

Here i cut my code, just the regex problem part :

#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;
}

It keeps giving me stack overflow error

Unhandled exception at 0x003EC447 in TestRegex.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x00E02FDC).

Also in codeblocks i could just use this regex format but when i move to visual studio it just doesn't work :

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

got closed said same problem with other question, but when i open, it's basically nothing in the question, i'm not sure, in my case the regex is working with other compiler, it's just when i move to visual studio getting this problem :|

c++
regex
visual-studio-2015
asked on Stack Overflow Nov 3, 2017 by izmanq • edited Nov 3, 2017 by izmanq

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0