ASP保留格式截取内容函数(无损HTNL)
<%
Function LeftH(str,l)
dim labelt,labels
dim ishtml
ishtml=false
dim res
dim c,c2
dim n
n=0
dim maxlen
maxlen=len(str)
dim i
i=0
dim b,e
do while n<l and i<maxlen
i=i+1
c=mid(str,i,1)
if c="<" then
c2=mid(str,i+1,1)
ishtml=true
b=i
end if
res=res+c
if ishtml=false then
n=n+1
else
if c=">" then
if ishtml=true and c2<>"/" then
labels=mid(str,b+1,i-b)
e=InStr(labels," ")
if e>0 then
labels="</"+left(labels,e-1)+">"
else
labels="</"+labels
end if
labelt=labels+labelt
end if
ishtml=false
end if
end if
loop
leftH=res+labelt
end function
%>
