How to handle \ (backslash) in regular expressions
I have a client application that presents the user with a dialog and requests input of a regular expression to search on via a text box. The resulting string is passed via a web service call to another application which executes a SQL query against an oracle database using the supplied regular expression.
My problem is that the user has no knowledge of java, but is familiar with regular expressions.
So, for example if they wanted to search for the string "asdf" preceded by a tab, they would enter \tasdf. I believe that java would convert this into an actual tab followed by asdf which is not what I need.
To further complicate matters, if the user wanted to search for the literal string "\tasdf" they would enter \\tasdf.
I think maybe what I need to do is search the string for \ and replace with \\.
Does that sound right? If so how would I handle \\tasdf?
Any help would be much appreciated.
A confused C++ developer.