In a legacy codebase, developed with Qt4.8, C++, for an ASCII-based application, I saw the following lines
const QRegExp lBadCharsRegExp("[^\\x{001F}-\\x{007E}]");
// if we find a match, our string contains some bad chars
bool lMatches = xStr.contains(lBadCharsRegExp);
The character class in the QRegExp is weird. It looks like the author was aiming for a range of hex characters, but the curly braces are unneeded. Moreover, if I pass in a string containing every printable character, it rejects just '~'. If I instead do
const QRegExp lBadCharsRegExp("[^\\x001F-\\x007E]");
the '~' is also accepted. Can someone explain
- the odd syntax in the first QRegExp
- why it excludes just '~'