无法使用Java中的.replaceAll方法替换所有字符吗?
我只需要https://www.example.co.uk输出到控制台窗口; {}#应替换为无字符。
我的方法:
public class Test {
public static void main(String[] args) {
String test = "#{https://www.example.co.uk}#";
System.out.println(test.replaceAll("{}", ""));
}
}
异常消息:
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition
{}
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.closure(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at BuyAGiftFramework.Test.main(Test.java:8)