Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to remove \ from a String

 
Qarabagi Jaan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How to remove \ from a String.
I used
But I got java.util.regex.PatternSyntaxException.
Thanks in advance
Qarabagi
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not exactly what I'd call "advanced".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic