您的位置:首页 > Web前端 > HTML

如何从Html页面中提取所有汉字及字符,不能有其它Html代码.

2006-05-11 09:56 966 查看
<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>

-----------------------------------------------------------------------

Function LoseHtml(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = "<//*[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseHtml = ClsTempLoseStr
End function
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐