为大家提供专业的保定网站制作保定网站建设保定网页设计保定网站策划保定网站推广服务。我们将SEO技术与网站制作******的结合,让您的网站更具竞争力!
服务电话:13171905859
网站制作

原创asp代码截取字符串

发布人:管理员   发布时间:2010-12-29
    在进行网站建设时,我们常常会因为各种需求而要对某一字符串数量进行限制,这时asp脚本就显得非常有价值了,下面就由保定网站建设公司技术人员给大家写了一段原创的asp截取字符串的方法,仅供参考。
<%
function website(str,strlen)
if str="" then
website=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
website=left(str,i)
exit for
else
website=str
end if
next
website=replace(replace(replace(replace(website," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function
%>
    一个汉字为两个字符,一个英文字母是一个字符,str为字符串,strlen是要截取的字符数,具体用法例如:<%=website("保定网站建设公,保定网站制作,保定网络公司",20)%>
公司地址:保定市复兴路利家世纪城7号楼2-1303 邮编:071051 公司邮箱:384697065@qq.com
服务热线:0312-6770690、15128291748、13171905859 售后电话:13754429971 投诉电话:13171905859
版权所有:【科泉网络】 Copyright © 2010-2018 All Rights Reserved www.pg-stone.com 冀ICP备07500686号