0
HTML = EntityUtils.toString(response.getEntity());
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String ResponseBody = httpclient.execute(httppost, responseHandler);
table = ResponseBody.substring(ResponseBody.indexOf("<table border=\"1\" cellpadding=\"0\" width=\"100%\" cellspacing=\"0\">"));
table = table.substring(0, table.indexOf("</table>"));
String htmlString = table;
String noHTMLString = htmlString.replaceAll("\\<.*?\\>", "");
noHTMLString = noHTMLString.replaceAll("\r", "<br/>");
noHTMLString = noHTMLString.replaceAll("\n", " ");
noHTMLString = noHTMLString.replaceAll("\'", "'");
noHTMLString = noHTMLString.replaceAll("\"", """);
TextView WORK = (TextView) findViewById(R.id.HTML);
WORK.setText(htmlString);
我正在使用正则表达式来提取HTML
代码。这是我的代码。这似乎是正确的,但表(子字符串)是什么被返回而不是提取的文本。有谁知道为什么?从源代码剥离html标记
这是不可能的使用正则表达式来解析HTML。而是使用HTML解析库。 – DwB 2013-03-19 15:02:34
[RegEx match open tags not XHTML self-contained tags]可能重复(http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags)必须在这里阅读答案。这真是太棒了(并且对SO最有帮助的答案) – Simon 2013-03-19 15:05:29
谢谢你们我最终不得不改变整个过程,把它放到一个二维数组中。 – user2187017 2013-03-31 15:29:56