유용한 함수(HTML 값 걸러내기)2
Posted by Albert 4932Day 19Hour 8Min 27Sec ago [2011-10-18]
'------------------------HtmlTagRemover -- HTML 테그 제거 함수 -------by Andy---------
' 파라미터 설명 : (처리할문자열, 자를길이)
' cutlen = 0 일경우 전체 문자열
'---------------------------------------------------------------------------------------
Function HtmlTagRemover(content, cutlen)
j=1
tmpb=2
length = len(content)
htmlRemovedContent = content
Do while length > 0
k = mid(htmlRemovedContent,j,1)
if k="<" then
tmpb = 0
elseif k = ">" then
tmpb = 1
end if
if tmpb = 0 then
htmlRemovedContent = left(htmlRemovedContent,j-1) & mid(htmlRemovedContent,j+1)
elseif tmpb = 1 then
htmlRemovedContent = left(htmlRemovedContent,j-1) & mid(htmlRemovedContent,j+1)
tmpb = 2
else
j=j+1
end if
length = length -1
loop
if cutlen <> 0 then
htmlRemovedContent = left(htmlRemovedContent, cutlen)
end if
HtmlTagRemover = htmlRemovedContent
End Function
'==========================================================
' 2번째 HTML 제거함수
'==========================================================
Function deleteHtmlTag(cont)
dim contTmp
set tagfree = New Regexp
tagfree.Pattern= "<[^>]+>"
tagfree.Global=true
cont =tagfree.Replace(cont,"")
deleteHtmlTag = cont
End Function