欢迎光临
我们一直在努力

如何从Html页面中提取所有汉字-ASP教程,ASP技巧

建站超值云服务器,限时71元/月

<script language=”vbscript”>
dim str
str=”怎样从一个html页面中提取所有汉字呢?不能有其它html代码。”
alert filterchinese(str)

function filterchinese(strinput)
dim result:result=””
dim tempstr
for i=1 to len(strinput)
tempstr=mid(strinput,i,1)
if left(escape(tempstr),2)=”%u” then
result=result & tempstr
end if
next
filterchinese=result
end function

 </script>

if asc(tempstr)>255 then

用正则表达式的方法
<script language=”vbscript”>
dim str
str=”怎样从一个html页面中提取所有汉字呢?不能有其它html代码。”
alert regexptest(“[\u4e00-\u9fa5]”,str)

 

function regexptest(patrn, strng)
   dim regex, match, matches   建立变量。
   set regex = new regexp   建立正则表达式。
   regex.pattern = patrn   设置模式。
   regex.ignorecase = true   设置是否区分大小写。
   regex.global = true   设置全局替换。
   set matches = regex.execute(strng)   执行搜索。
   for each match in matches   遍历 matches 集合。
      retstr = retstr  &  match.value
   next
   regexptest = retstr
end function

 </script>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何从Html页面中提取所有汉字-ASP教程,ASP技巧
分享到: 更多 (0)