'html태그제거'에 해당되는 글 1건

  1. 2008.04.15 문자열에서 HTML 태그 제거

String noHTMLString = htmlString.replaceAll("\\<.*?\\>", "");


String regex1 = "\\<.*?\\>";
String regex2 = "<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>";
String html = "가<aaa>나</bbb>다<ccc/>라<한글>마<ddd >바< eee >사< img src=\"한글\" >아\n";
System.out.println(html.replaceAll(regex1, ""));
System.out.println(html.replaceAll(regex2, ""));

==== 실행결과 ======
가나다라마바사아
가나다라<한글>마바< eee >사< img src="한글" >아


참고 사이트
http://snippets.dzone.com/posts/show/4018 
http://javacan.madvirus.net/main/content/read.tle?contentId=122 (최범균님)

http://forum.java.sun.com/thread.jspa?threadID=683818&messageID=3983002
http://www.rgagnon.com/javadetails/java-0424.html
http://java-source.net/open-source/html-parsers
Posted by 에코지오
,