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