java中双引号的问题

发布于 2024-12-05 10:17:09 字数 263 浏览 7 评论 0原文

当我从字段中获取值时,我从数据库中获取三种类型的值。

所有值都带有双引号。这些值为“健身头健身“头健身头”。我必须使用 Java 代码将所有双引号替换为 double 双引号,

谢谢, 索姆纳特

I am getting three types of value from the database when I am fetching value from a field.

All values are with double quotes. Those values are "Fitness Head, Fiteness " Head and Fitness Head". I have to replace all double quotes with double double quotes using Java. What will be the java code to do that?

Thanks,
Somnath

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

谎言 2024-12-12 10:17:09

如果您使用 JDBC 插入/获取值,则无需在任何地方替换双引号 - 只要您使用 PreparedStatement 和占位符,这一切就可以解决。

请参阅本教程

You don't need to replace double quotes anywhere if you are using JDBC to insert/fetch the values - this is all taken care of as long as you use PreparedStatements and placeholders.

See this tutorial.

尴尬癌患者 2024-12-12 10:17:09

使用 String.replace

例如

String doubleQuotes = "\"Fitness head";
doubleQuotes.replace("\"", "\"\"");

Use String.replace

For example

String doubleQuotes = "\"Fitness head";
doubleQuotes.replace("\"", "\"\"");
风尘浪孓 2024-12-12 10:17:09

将单双引号替换为双双引号:

"abc\"def".replace("\"", "\"\"")

Replacing single double quotes with double double quotes:

"abc\"def".replace("\"", "\"\"")
﹂绝世的画 2024-12-12 10:17:09

怎么样:

String newValue = oldValue.replace("\"", "\"\"");

What about this:

String newValue = oldValue.replace("\"", "\"\"");

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文