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.

1
  • These aren't "ascii characters", they are HTML entities. Commented Mar 19, 2019 at 11:28

2 Answers 2

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("'","\'");
Sign up to request clarification or add additional context in comments.

Comments

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'));

}

}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.