PDA

View Full Version : Simple RegExp Question...



jared.carlson23
4th July 2008, 01:04
Hey, I know this is a newbie question, and that's what I am.. but if I want to detect a double quote, I'm trying..

QRegExp rx("\\"");

which doesn't work... so what's the proper syntax for quotes in Qt? In PHP, Python that would be fine - except I'd only need one \ for the escape, two here.. but clearly I'm doing something wrong... any pointers?

Gnurou
4th July 2008, 14:10
QRegExp rx("\\"");


Your second \ is escaped by the first one, which means the C compiler ends the string right after it and starts a new one. This example does not even compile. The correct syntax would be:


QRegExp rx("\\\"");

Here both the second \ and " are escaped, so the string that is passed to the constructor is \", which is what you expect.