gpt4 book ai didi

java - 如何使用 replaceAll 函数过滤掉双引号

转载 作者:行者123 更新时间:2023-11-29 05:20:15 25 4
gpt4 key购买 nike

我正在尝试过滤包含 "符号的字符串。我使用函数 replaceAll 来消除不需要的 "但出现错误。

这是我的表达:

str[i] = str[i].replaceAll("["]", null);

错误信息如下:

Multiple markers at this line - Syntax error, insert ")" to complete MethodInvocation - Syntax error, insert ";" to complete BlockStatements - The method replaceAll(String, String) in the type String is not applicable for the arguments (String)

我知道 eclipse 将 [ ] 中的 "引号视为我要替换的字符串的边界。谁能给我正确的表达方式?

最佳答案

试试 replaceAll("\"","");

你不想使用 null,你想使用空字符串。

关于java - 如何使用 replaceAll 函数过滤掉双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25111371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com