如何用Java中的空格替换双引号? [英] How do you replace double quotes with a blank space in Java?

查看:472
本文介绍了如何用Java中的空格替换双引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

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

我希望输出

I don't like these double quotes


推荐答案

使用 String#replace()

用空格替换它们(根据你的问题标题):

To replace them with spaces (as per your question title):

System.out.println("I don't like these \"double\" quotes".replace("\"", " "));

以上也可以用字符:

System.out.println("I don't like these \"double\" quotes".replace('"', ' '));

删除它们(根据你的例子):

To remove them (as per your example):

System.out.println("I don't like these \"double\" quotes".replace("\"", ""));

这篇关于如何用Java中的空格替换双引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆