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);
基本上我想从一个包含的Java删除子字符串,其中包括引号
<span title="Representation in the International Phonetic Alphabet (IPA)" class="IPA">no'b?l</span>
但是文件中删除这个字符串
<span title="Representation in the International Phonetic Alphabet (IPA)" class="IPA">
到目前为止,如果我的代码只能字符串不包含引号。我该如何解决这个问题。我曾尝试过使用
.replaceAll("\\\"","\\\\\"");
但仍然失败。
任何帮助或信息将大大apreciated。
您应该使用HTML解析器。 – SLaks
是的,这就是我最终想要的,而且这段代码没有引号就能正常工作。 – Jake
请参阅http://stackoverflow.com/questions/240546/removing-html-from-a-java-string。它非常简单 – itsadok