6

I need some help to replace all the single quotes in a string.

This is my string: The State of the water = 'ICE'

I want to remove the single quotes around ICE.

fiddle
  • 1,095
  • 5
  • 18
  • 33
  • 2
    Did you take a look at `String.replace()` method? – Codebender Aug 12 '15 at 08:01
  • 3
    i just googled the title of your question - the results were shocking – Tator Aug 12 '15 at 08:01
  • possible duplicate of [String replace a Backslash](http://stackoverflow.com/questions/5596458/string-replace-a-backslash) or at least very similar (no need for separate question for replacing any possible character) – Chris Aug 12 '15 at 08:06
  • 1
    possible duplicate of [replace String with another in java](http://stackoverflow.com/questions/5216272/replace-string-with-another-in-java) – Mikk Aug 12 '15 at 08:06

2 Answers2

10
str = str.replaceAll("\'","");
wawek
  • 1,577
  • 1
  • 13
  • 23
3

Use this

String str = "The State of the water = 'ICE'";
str = str.replaceAll("'","");
Harshit
  • 5,147
  • 9
  • 46
  • 93