String replace a Backslash

sSource = sSource.replace("\\/", "https://stackoverflow.com/");
  • String is immutable – each method you invoke on it does not change its state. It returns a new instance holding the new state instead. So you have to assign the new value to a variable (it can be the same variable)
  • replaceAll(..) uses regex. You don’t need that.

Leave a Comment