Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

simple string replace question  RSS feed

 
Ravi Shankarappa
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

In a string, how do I replace all occurrences of "\" by "\\" ?.

Thanks in advance.

-Ravi
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By using String.replace(CharSequence, CharSequence) - String implements CharSequence so you can use String literals. Unlike String.replaceAll, this method doesn't take regular expressions so you need a lot less escaping.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!