如何从Html页面中提取所有汉字及字符,不能有其它Html代码.
2006-05-11 09:56
1011 查看
<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
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
相关文章推荐
- 如何从Html页面中提取所有汉字
- [代码]HTML页面如何接收外部参数
- [HTML/JS]利用JQuery的load函数动态加载其它页面的内容的实现代码代替Ifram
- Python中如何进行HTML特殊字符与Unicode代码的转换
- 如何在html页面上随着鼠标的位置显示浮动层图片或别的东东?(附代码)
- 1-100之间的所有素数的和如何在JSP页面实现 代码如下
- 如何直接在Web html页面运行coffeescript代码
- 如何用正则过滤所有html字符?
- 如何在HTML页面引入javaScript代码
- 如何让html页面中所有连接打开新页面
- asp.net中如何把一个字符串中的所有html代码去掉成为文本模式
- php代码从html代码中提取出所有的图片返回数组
- 如何在html、php、jsp、asp等页面中添加分析代码(跟踪代码)
- HTML文本框中怎么限制输入字符(因为页面会认为英文和汉字是一样的)
- [代码]HTML页面如何接收外部参数
- 正则表达式应用--提取CSDN所有下载资源页面URl的思路与代码实现
- j2ee的web项目,在浏览器中发起一个该项目中html页面的绝对地址,也是发起的一个http url请求,请求的响应报文的结果就是该html页面的所有html代码
- 2.response跳转: a.客户端跳转,地址栏改变; b.所有代码执行完毕后跳转; c.跳转后的页面不能使用上一个页面的request属性; d.使用地址重写传递参数(respon
- js replace 全局替换 以表单的方式提交参数 判断是否为ie浏览器 将jquery.qqFace.js表情转换成微信的字符码 手机端省市区联动 新字体引用本地运行可以获得,放到服务器上报404 C#提取html中的汉字 MVC几种找不到资源的解决方式 使用Windows服务定时去执行一个方法的三种方式
- 如何查看以XML为后缀的HTML代码——DHTML作业中获得页面元素的小方法