아는 것이 좋은 것이다.

[ASP] HTML 태그 제거 본문

ASP

[ASP] HTML 태그 제거

start0 2014. 4. 24. 21:32
<%
'HTML벗겨내기
Function DeleteHTML( strText )
	dim contTmp
	set onlyTex = New Regexp
	onlyTex.Pattern= "<[^>]+>"
	onlyTex.Global=true
	strText=onlyTex.Replace(strText," ") ' 구분을 위해 한칸 뛰어쓰기
	DeleteHTML= strText
End Function
%>


사용하는 예

contents = "<table border='1'><tr><td>텍스트</td></tr></table><img src='aa.jpg'/><div>텍스트!!!</div>"
Response.write "기존 텍스트 : " & contents
contents = DeleteHTML(contents)
Response.write "제거 후 텍스트 : " & contents
'contents에는 HTML 태그가 제거되고 순수 텍스트만 남는다.

Comments