用正則表達式取出去除html頁面中的tags
這個就比較簡單了,正則式是 “<[^>]*>”,其表意為“以<開頭的,后續任意個不為>的字符,并以>結尾的字符串”這樣做的目的是為了獲得所謂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
