Reputation: 2281
I've got following regex which seems to be a valid regex according to regex coach but qt's regexp.isValid says something else. Could anyone tell me what's the story with this expression:
^[^,\.:;\*<>\[\]\+\"\\\/]+\.cpp$
Upvotes: 0
Views: 171
Reputation: 179779
/
should not be single-escaped. It's a regular character in C++.
[
nor *
need regex escaping inside a class.
.
needs regex escaping, not C++ escaping.
Rules:
\\
So:
"^[^,\.:;*<>[\\]\+\"\\/]+\\.cpp$"
Upvotes: 1
Reputation: 92976
According to http://doc.qt.nokia.com/latest/qregexp.html Qt/C++ needs double escaping, so try to double each backslash like this:
^[^,.:;*<>[\\]+"\\\\/]+\\.cpp$
I removed also some of them, because inside a character class they don't need to be escaped.
Upvotes: 0