Hi i am using below code to replace the single quote with the '
but it's not working could you please help me out on this?
String name = "Hello's";
name.replaceAll("/'/g", "'");
System.out.println(name);
Hi i am using below code to replace the single quote with the '
but it's not working could you please help me out on this?
String name = "Hello's";
name.replaceAll("/'/g", "'");
System.out.println(name);
You have to assign your variable with your new value.
String name = "Hello's";
name = name.replaceAll("'", "'");
System.out.println(name);
Hope it helps.
In Java, strings are immutable. replaceAll
returns a new string and you should use that, not the original string.