Results 1 to 2 of 2
- 11-02-2008, 01:22 AM #1Member
- Join Date
- Nov 2008
- Rep Power
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.
- 11-02-2008, 02:33 AM #2I believe that java would
There is a difference in how the escape character is handled if you are including a String in a program to be compiled vs a program reading in a String.
- By blue404 in forum Advanced JavaReplies: 2Last Post: 09-26-2008, 04:43 AM
- By Java Tip in forum Java TipReplies: 0Last Post: 01-10-2008, 11:43 AM
- By Java Tutorial in forum Java TutorialReplies: 0Last Post: 01-07-2008, 01:46 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 12-25-2007, 12:19 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 12-25-2007, 12:18 PM