大家都知道汉字占用两个英文字母的长度,所以索取时要将其转换为长度2,这个例子比较简单的实现了这一功能
<script language=vbs> function find1(findstr) set rep1= new regexp rep1.Global= true rep1.IgnoreCase= true rep1.Pattern= "[\u4E00-\u9FA5]" set str1=rep1.Execute(findstr) for each i in str1 lens=lens+1 next lens=lens + len(findstr) msgbox "字符长度 : " & lens end function find1( "1234567" ) find1( "大家好1234567" ) </script>
查看更多关于VBS正则表达式获取字符串的"字节"数的实现方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did226717