std::tr1::regex re pattern matching

In Visual Studio 2010 I created the following console application:
// TestRegEx.cpp : main project file.

#include "stdafx.h"
#include <string>
#include <regex>

using namespace System;

int main(array<System::String ^> ^args)
std::string pattern("( ?h)+");
std::tr1::regex re(pattern, std::regex::ECMAScript);

bool bRet1 = std::tr1::regex_match("h", re);
bool bRet2 = std::tr1::regex_match(" h", re);
bool bRet3 = std::tr1::regex_match("hhh", re);
bool bRet4 = std::tr1::regex_match(" h h", re);

return 0;

When I step through the code in the debugger I see the following results:
I expected all four strings to match the pattern. My thinking was that any combination of 'h' or ' h' would match. Why does ' h h' not match?

Also, if I change the pattern to "( *h)+" then std::tr1::regex_match(" h h", re); does return true (along with " h h" and " h h h h" also returning true). Thank you in advance for any help in understanding the algorithm being used by the windows std regex library.
closed account (Dy7SLyTq)
i use perl re's, so i dont know if this would be the case with ECMAscript, but you had an h, and then it saw the +, so it needed to match again, but it hit a space so it stopped
I've learned now that when using Visual Studio 2008 the regular expression works as expected (' h h') does match. Appears to be a bug in the 2010 version of the regex library.
The most current version of std::regex in the release candidate works as expected. (It matches.)
Topic archived. No new replies allowed.