提取html中文字符,教你怎么在Html页面提取全部汉字

本文分享给大家学习的是如何从Html页面中提取所有汉字,希望通过下面的学习对大家有所帮助。

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

if asc(tempStr)>255 then

用正则表达式的方法

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值