asp 正则实现清除html文本格式的函数代码

复制代码 代码如下:

<%

'/* 函数名称:Zxj_ReplaceHtml ClearHtml

'/* 函数语言:VBScript Language

'/* 作  用:清除文件HTML格式函数

'/* 传递参数:Content (注:需要进行清除的内容)

'/* 函数作者:张晓军(古城童话) QQ:382511147

'/* 函数说明:正则匹配(正则表达式)模式进行数据匹配替换

Function ClearHtml(Content)

Content=Zxj_ReplaceHtml("&#[^>]*;", "", Content)

Content=Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?object[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?param[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?embed[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?table[^>]*>", "", Content)

Content=Zxj_ReplaceHtml(" ","",Content)

Content=Zxj_ReplaceHtml("</?tr[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?th[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?td[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?script[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content)

Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content)

Content=Zxj_ReplaceHtml("<\\?xml[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("<\/?[a-z]+:[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?font[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content)

ClearHtml=Content

End Function

Function Zxj_ReplaceHtml(patrn, strng,content)

IF IsNull(content) Then

content=""

End IF

Set regEx = New RegExp ' 建立正则表达式。

regEx.Pattern = patrn ' 设置模式。

regEx.IgnoreCase = true ' 设置忽略字符大小写。

regEx.Global = True ' 设置全局可用性。

Zxj_ReplaceHtml=regEx.Replace(content,strng) ' 执行正则匹配

End Function

%>

时间: 2024-07-31 21:09:17

asp 正则实现清除html文本格式的函数代码的相关文章

asp 正则实现清除html文本格式的函数代码_应用技巧

复制代码 代码如下: <% '/* 函数名称:Zxj_ReplaceHtml ClearHtml '/* 函数语言:VBScript Language '/* 作 用:清除文件HTML格式函数 '/* 传递参数:Content (注:需要进行清除的内容) '/* 函数作者:张晓军(古城童话) QQ:382511147 '/* 函数说明:正则匹配(正则表达式)模式进行数据匹配替换 Function ClearHtml(Content) Content=Zxj_ReplaceHtml("[^&

asp.net动态获取Excel表名的函数代码

复制代码 代码如下: public string GetExcelFirstTableName(string excelFileName) { string tableName = null; if (File.Exists(excelFileName)) { using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet." + "OLEDB.4.0;Extended Properties=

asp.net动态获取Excel表名的函数代码_实用技巧

复制代码 代码如下: public string GetExcelFirstTableName(string excelFileName) { string tableName = null; if (File.Exists(excelFileName)) { using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet." + "OLEDB.4.0;Extended Properties=

ASP.NET动态输出Javascript文本格式换行问题

前言 在动态输出Javascript的时候我们习惯用Response.write("<script language=\"javascript\" type=\"text/javascript\">alert(1);</script>");这样的语句来动态输出,但是你可能没注意到里面的格式问题,比如,我测试连接数据库,如果连接失败就打印catch信息,但是你会发现你直接输出是输出不了的,会报错,比如字符串没有结束之类的脚本

Asp.net导出Excel/Csv文本格式数据的方法_实用技巧

刚刚开始做Excel相关的项目,所以遇到的问题不管大小都给记录一下 偶然的机会在添加数据的时候全改成了数字,结果输出的时候全自动变成了科学计数法,这是excel的强大功能,能自动识别数字和字符串,太聪明了反而有些麻烦,就像如果输入身份证(18位数字)的话那就不行了.超过了11位呢,下面查了些资料总结一下解决方案: 方法1: 在往excel中添加数据的时候在数据的前面加 单引号,我的是这个方法解决的 如:Sheet.Cells[iRow, iCol] ="'"+ ds.Tables[0]

asp 下用正则表达式检测邮箱格式的函数_应用技巧

'********************************************************* '函数:IsValidEmail[str] '参数:str,待处理的字符串 '作者:木木 '日期:2007/7/12 '描述:检测邮箱格式是否为xxxx@xxx.com或者xxxx@xxx.com.cn等格式 '示例:<%=IsValidEmail(ali@alixixi.com)%> '*********************************************

asp 下用正则表达式检测邮箱格式的函数

'********************************************************* '函数:IsValidEmail[str] '参数:str,待处理的字符串 '作者:木木 '日期:2007/7/12 '描述:检测邮箱格式是否为xxxx@xxx.com或者xxxx@xxx.com.cn等格式 '示例:<%=IsValidEmail(ali@alixixi.com)%> '*********************************************

ASP和javaScript中的字母大小写转换函数代码

  ASP中的字母大小写转换代码,同时也给出了javascript中的代码,二者大家可参考比较,下面先来看ASP中的,脚本引擎基于VBScript: VBScript代码: str = "abcdE" str = UCASE(str) '大写 str = LCASE(str) '小写 JavaScript中的字母大小写转换,同样简单: str = "abcdE";str = str.toUpperCase();//大写str = str.toLowerCase();

ASP 支持中文的len(),left(),right()的函数代码

Function Strlength(Str) Temp_Str=Len(Str) For I=1 To Temp_Str Test_Str=(Mid(Str,I,1)) If Asc(Test_Str)>0 Then Strlength=Strlength+1 Else Strlength=Strlength+2 End If Next End Function Function Strleft(Str,L) Temp_Str=Len(Str) For I=1 To Temp_Str Test