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 How to remove \ from a String Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to remove \ from a String" Watch "How to remove \ from a String" New topic
Author

How to remove \ from a String

Qarabagi Jaan
Greenhorn

Joined: May 03, 2004
Posts: 7
Hi,
How to remove \ from a String.
I used
But I got java.util.regex.PatternSyntaxException.
Thanks in advance
Qarabagi
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2341
You need to add two more slashes in the first String. The pattern is sent to another class before it is processed, so you need to make sure you have enough escapes.
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
This works for me:



Or according to Keith



Or the simple form



[ October 03, 2006: Message edited by: Edwin Dalorzo ]
[ October 03, 2006: Message edited by: Edwin Dalorzo ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56540
    
  14

Not exactly what I'd call "advanced".


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to remove \ from a String
 
Similar Threads
String Replacement problem
readonly field value change
remove " from String
Remove Chars from a String?
Remove last character from a string