Search code examples
c++regextr1

Regular expressions matching


I have one function for checking, whether entered line is "OK".

#include <tr1/regex>

bool lineIsValid(string line) {
    const tr1::regex pattern("[^-]{1,30} - [^-]{1,30}");
    return tr1::regex_match(line, pattern);
}

lineIsValid("test - test");

the function returns false. Why?


Solution

  • Perhaps the syntax is ok, but depends on the implementation. Check this post.

    Or this:

    After further investigation, I (we) have determined that the TR1 framework supplied by Microsoft with Visual Studio 2008 [and some very early versions of Visual Studio 2010] is buggy, which makes me wonder why the other regex's supplied by Dinkumware are not buggy. Or are they?