0

I have a string Hi , Thank you for opening an account with XYZ. We're excited to have you on board.

I need to get rid of ' from the string and get equivalent character in place of it which is apostrophe (').

I need general code to replace the ascii characters.

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175

2 Answers2

1

Use String.replace():

String str = "Hi , Thank you for opening an account with XYZ. We're excited to have you on board.";
str.replace("'","\'");
Strom
  • 5,352
  • 1
  • 10
  • 34
0

Here is example

public class Guru99Ex1 {
public static void main(String args[]) {
    String S1 = new String("the quick fox jumped");
    System.out.println("Original String is ': " + S1);
    System.out.println("String after replacing 'fox' with 'dog': " + S1.replace("fox", "dog"));
    System.out.println("String after replacing all 't' with 'a': " + S1.replace('t', 'a'));

}

}

ATIQ UR REHMAN
  • 391
  • 2
  • 12