字符串截取的几个function


function cutstr(thestr,strlen) dim l,t,c l=len(thestr) t=0 for dxy=1 to l c=Abs(asc(Mid(thestr,dxy,1))) if c>255 then t=t+2 else t=t+1 end if if t>=strlen then thev=left(thestr,dxy) exit for else bu=strlen-t for bui=1 to bu strbu=" " strbuall=strbuall&strbu next thev=thestr&strbuall strbu="" strbuall="" end if next cutstr=thev end function

Response.write(cutstr("fdsafdsafdsafdsafdasfdsa",10)&"<br>")

'============================ '函数名CutTrueStr(type,num) '作用:字符串截取 '参数type,num 'type:字符串内容 'num:字符串被截取的长度 '=============================

Function CutTrueStr(types,num) dim ctypes,cnum,ci,tt,tc,cc ctypes=types:cnum=int(num):CutTrueStr="":tc=0:cc=0 for ci=1 to len(ctypes) if cnum<0 then CutTrueStr=CutTrueStr&"...":exit for tt=mid(ctypes,ci,1) if int(asc(tt))>=0 then CutTrueStr=CutTrueStr&tt tc=tc+1:cc=cc+1 if tc=2 then tc=0:cnum=cnum-1 end if if cc>5 then cnum=cnum-1:cc=0 else cnum=cnum-1 if cnum<=0 then CutTrueStr=CutTrueStr&"...":exit for CutTrueStr=CutTrueStr&tt end if next End Function

Response.write(CutTrueStr("时髦里面脸色有声有色fdsafdsafdsafdsafdsafdsafdsafdsafdsafdsa",10))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值