我应该如何{从字符串中删除所有出现的这个字符?我知道我应该使用replaceAll方法,但这不起作用?
String str = "this is {something";
str = str.replaceAll("{", "");
Run Code Online (Sandbox Code Playgroud)
replaceAll使用正则表达式作为其参数.{在正则表达式中用于表示匹配的出现,因此需要对其进行转义
str = str.replaceAll("\\{", "");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45 次 |
| 最近记录: |