Problem with whitespace in regular expression

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
menashe
Forum Newbie
Posts: 1
Joined: Mon Aug 17, 2009 7:23 am

Problem with whitespace in regular expression

Post 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?
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Problem with whitespace in regular expression

Post by prometheuzz »

The regex looks fine. I suggest posting in a C++/C forum instead (this is a PHP forum).
Post Reply