I\'m using the following regex
^[a-zA-Z0-9\\\',!;\\?\\$\\^:\\\\\\/`\\|~&\\\" @#%\\*\\{}\\(\\)_\\+\\.\\s=-]{1,1000}$
I know it\'s ugly,
If it's not a literal, you have to use \\\\
so that you get \\
which means an escaped backslash.
That's because there are two representations. In the string representation of your regex, you have "\\\\"
, Which is what gets sent to the parser. The parser will see \\
which it interprets as a valid escaped-backslash (which matches a single backslash).