This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to remove \ from a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
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: 2367
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: 60077
    
  65

Not exactly what I'd call "advanced".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to remove \ from a String
 
Similar Threads
remove " from String
String Replacement problem
Remove Chars from a String?
Remove last character from a string
readonly field value change