我正在尝试用“”(Null)
替换下面的内容java.util.regex.PatternSyntaxException: Syntax error U_REGEX_BAD_INTERVAL near index 50:
01-05 14:11:14.660: E/AndroidRuntime(1546): FATAL EXCEPTION: main
01-05 14:11:14.660: E/AndroidRuntime(1546): java.util.regex.PatternSyntaxException: Syntax error U_REGEX_BAD_INTERVAL near index 50:
01-05 14:11:14.660: E/AndroidRuntime(1546): <html><head> <style type="text/css">@font-face { font-family: MyCustomFont; src: url("file:///android_asset/fonts/MyriadPro-Regular.otf") }body { font-family: MyCustomFont; font-size:14.0pt; text-align: center;vertical-align:middle;line-height: normal;} </style> </head><body>
我发现这个错误这里有什么问题?
修改
这是我的代码
"a"
包含带标记的值
<html><head> <style type="text/css">@font-face { font-family: MyCustomFont; src:
url("file:///android_asset/fonts/MyriadPro-Regular.otf") }body { font-family:MyCustomFont;
font-size:14.0pt; text-align: center;vertical-align:middle;line-height: normal;} </style>
</head><body>365<i>xy</i></body></html>
val =<html><head> <style type=\"text/css\">"
+ "@font-face { font-family: MyCustomFont; src: url(\"file:///android_asset/fonts/MyriadPro-Regular.otf\") }"
+ "body { font-family: MyCustomFont; font-size:"14.0pt"; text-align: center;vertical-align:middle;line-height: normal;}</style></head><body>
a.getText().replaceAll(val, "")
答案 0 :(得分:0)
尝试
a.getText().replaceAll(java.util.regex.Pattern.quote(val), "")
这将引用模式中的特殊字符。
顺便说一下。这是一种非常脆弱的删除标题的方法。如果标题稍有改变,它将不再被删除。