File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes regular expressions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "regular expressions" Watch "regular expressions" New topic
Author

regular expressions

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
hi friends,

I need to escape of single quote "'" and backslash "\".
is the following doing this?




later i need to return to the original string, do i need to do this:




We must know, we will know. -- David Hilbert
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

a) looks like if you're trying to escape double quotes, not backslash.
b) to replace a backslash by an 'x', use:

The regexpressions use backslash as escape-character, so you have to give two of them.
But javac uses an backslash as escape-character too, so you have to preceede every backslash with another one, which leads to 4 backslashes in total.
Fortunately bb-code doesn't use backslashes itself - else I had to use 8 to make you see 4.

If you use a variable, you may print it out, if things get more complex:

[ May 12, 2005: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: regular expressions