精美而实用的网站,关注web编程技术、网站运营、SEO推广,让您轻松愉快的学习

ASP函数名:StrLength 作用:获取指定字符串的长度(汉字为2个字节) 函数参数:str ——需要统计长度的字符串内容,返回值:字符串长度,一般是数字值。

ASP获取字符串长度的函数

Public function StrLength(str)
   Dim Rep,lens,i
   Set rep=new regexp
   rep.Global=true
   rep.IgnoreCase=true
   rep.Pattern="[\u4E00-\u9FA5\uF900-\uFA2D]"
   For each i in rep.Execute(str)
    lens=lens+1
   Next
   Set Rep=Nothing
   lens=lens + len(str)
   strLength=lens
End Function

查看函数运行结果,可以这样:<%=StrLength("青岛星网")%>

Tags:ASP 字符串 函数