How do you replace double quotes with a blank space in Java?

前端 未结 4 1059
谎友^
谎友^ 2020-12-16 10:55

For example:

\"I don\'t like these \"double\" quotes\"

and I want the output to be

I don\'t like these double quotes
         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 11:11

    You don't need regex for this. Just a character-by-character replace is sufficient. You can use String#replace() for this.

    String replaced = original.replace("\"", " ");
    

    Note that you can also use an empty string "" instead to replace with. Else the spaces would double up.

    String replaced = original.replace("\"", "");
    

提交回复
热议问题