1. 程式人生 > >JAVA去除A標籤和IMG標籤

JAVA去除A標籤和IMG標籤

	public static void main(String[] args) {
		String contentString = "sdfsd abc---abc <a href='http://www.hao123.com'>" +
				"http://www.hao123.com</a><img title='img' src='abc' />" +
				"sdfsdfds";
		contentString=contentString.replaceAll("<a href[^>]*>", "");
		contentString=contentString.replaceAll("</a>", "");
		contentString=contentString.replaceAll("<img[^>]*/>", " ");
		System.out.println(contentString);
	}