【发布时间】:2011-10-02 18:27:10
【问题描述】:
String strLine = "";
try
{
BufferedReader b = new BufferedReader(new FileReader("html.txt"));
strLine = b.readLine();
} catch(Exception e)
{
e.printStackTrace();
}
String[] temp = strLine.split("<");
temp = temp[1].split(">");
String temp1 = ("<"+temp[0]+">");
strLine = strLine.replaceFirst(temp1,"");
System.out.println(strLine);
基本上我想删除这个字符串
<span title="Representation in the International Phonetic Alphabet (IPA)" class="IPA">
来自包含
的文件<span title="Representation in the International Phonetic Alphabet (IPA)" class="IPA">no'b?l</span>
但是到目前为止,我的代码仅在字符串不包含引号时才有效。我该如何解决这个问题。我试过使用
.replaceAll("\\\"","\\\\\"");
但还是失败了。
任何帮助或信息将不胜感激。
【问题讨论】:
-
你应该使用 HTML 解析器。
-
是的,这就是我最终想要的,这段代码没有引号也能正常工作。
标签: java string replace quotes