字符串截取的几个function

ASP常用函数
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)) 

相关内容推荐

asp过滤&lt;img&gt;图片的正则表达式函数

functionnoHTML(str) dimre Setre=newRegExp re.IgnoreCase=true re.Global=True ’re.Pattern="(\.[^\]*\)" ’str=re.replace(str,"") re.Pattern="(\img[^\]*\)" str=re.replace(str,"") nohtml=str setre=nothing endfunction

使用FSO修改文件特定内容的函数

function FSOchange(filename,Target,String) Dim objFSO,objCountFile,FiletempData Set objFSO = Server.CreateObject("scripting.FileSystemObject") Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True) FiletempData = objCountFil

字符串截取的几个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 c255 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=

删除html代码的正则表达式,RemoveHTML函数

Function RemoveHTML(strHTML) Dim objRegExp, Match, Matches Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = True '取闭合的 objRegExp.Pattern = ".+?" '进行匹配 Set Matches = objRegExp.Execute(strHTML) ' 遍历匹

ASP中获取汉字拼音的第一个字母

<script language="vbs" src=http://www.webjx.com/htmldata/2006-05-10/"spellcode.vbs" </script '获取客户简称的拼音缩写 function getpy() dim str dim i str=document.all.txtContactName.value dim ret for i=1 to len(str) ret=retgetp

返回
顶部