ASP函数名:StrLength 作用:获取指定字符串的长度(汉字为2个字节) 函数参数:str ——需要统计长度的字符串内容,返回值:字符串长度,一般是数字值。
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("青岛星网")%>

