欢迎来到山村网

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

2019-03-28 23:11:51浏览:934 来源:山村网   
核心摘要:SCRIPT LANGUAGE=vbScriptdim strstr=怎样从一个Html页面中提取所有汉字呢?不能有其它Html代码。alert FilterChinese(str)funct

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

(责任编辑:豆豆)
下一篇:

html禁止文本框输入

上一篇:

常用input文本框内容自动垂直居中并默认提示文字单击为空

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com