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("te开发者_如何学Pythonst - test");
the function returns false. Why?
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?
I would have thought that should match.
Is there potentially a bug in the implementation of the tr1 library? Maybe it is getting confused with the "-" that is used as the range specifier.
精彩评论