Page 1 of 1

Problem with whitespace in regular expression

Posted: Mon Aug 17, 2009 7:25 am
by menashe
I have the following simple code:

std::string str = "This is a simple test"
std::tr1::cmatch res;
std::tr1::regex rx("a(\\s+)sim");
std::tr1::regex_search(str.c_str(), res, rx);

which compiles correctly but fails at execution time with the following message:
Debug Assertion Failed!
Program test.exe
File f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c line 1511
Expression: _CrtIsValidHeappointer(pUserData)

Every other expression that does not contain \\s+ executes properly, but this one does not. I have tried the same with boost and it has teh same problem.

Any idea what could be wrong?

Re: Problem with whitespace in regular expression

Posted: Tue Aug 18, 2009 3:12 pm
by prometheuzz
The regex looks fine. I suggest posting in a C++/C forum instead (this is a PHP forum).