你的位置:首页 > 软件-代码-工具

ASP保留格式截取内容函数(无损HTNL)

September 3, 2010 | tags 无损HTNL截取字符  常用工具代码  网站常用代码   | views
Comments 0

<%
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


%>



作者:成都木木SEO 转载请注明出处。
联系木木SEO:QQ:631359592 电话:13408026909



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。