用正則表達(dá)式取出去除html頁(yè)面中的tags
這個(gè)就比較簡(jiǎn)單了,正則式是 “<[^>]*>”,其表意為“以<開(kāi)頭的,后續(xù)任意個(gè)不為>的字符,并以>結(jié)尾的字符串”這樣做的目的是為了獲得所謂plain的文本,方便下一步的處理。
代碼如下:
1
/**
2
* Remove all "<>" tags in the text
3
* @param tagText
4
* @return the clean text without tags
5
*/
6
public String removeTags( String tagText )
7
{
8
return tagText.replaceAll("<[^>]*>", "");
9
}

2

3

4

5

6

7

8

9

posted on 2009-11-06 22:19 甜菜侯爵 閱讀(202) 評(píng)論(0) 編輯 收藏