如何从Html页面中提取所有汉字

王朝html/css/js·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

<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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航