The list of characters that you have to escape depends on which of the various regular expression grammars you're using. If you're using the default ECMAScript
, it looks like the list in the QRegExp::escape
documentation is a good place to start. It says:
The special characters are $, (,), *, +, ., ?, [, ,], ^, {, | and }.
That list leaves out \
for some reason.
But it's slightly more complicated than that, because inside square brackets, none of the characters except \
and ]
are special, and \]
has to stay unescaped.
Further, a ?
that comes right after a (
is not special. For example, in (?=x)
the ?
should not be escaped.
I think that's pretty much it, but I haven't put enough time into this to be sure.