过滤掉全部html标记的正则表达式怎么写?

hetoo 2006-06-10 10:59:23
包括:<a href=""></a> <br> <p></p> <img src=""> <span></span> <font ></font> <script></script> <input >.......等等
...全文
310 14 打赏 收藏 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
future914 2006-08-11
  • 打赏
  • 举报
回复
Public Function RemoveHtml(ByVal strHTML) As String
Dim Pattern = "<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(\\[""'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>"
strHTML = System.Text.RegularExpressions.Regex.Replace(strHTML, Pattern, String.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase)
strHTML = strHTML.Replace(" ","")
Return strHTML
End Function
Yaba_lx 2006-08-09
  • 打赏
  • 举报
回复
function delhtml(strhtml)
dim objregexp, stroutput
set objregexp = new regexp
objregexp.ignorecase = true
objregexp.global = true
objregexp.pattern = "(<[a-zA-Z].*?>)|(<[\/][a-zA-Z].*?>)"
stroutput = objregexp.replace(strhtml, "")
delhtml = stroutput
set objregexp = nothing
end function
lip009 2006-08-09
  • 打赏
  • 举报
回复
晕死...
上面抄来的是错的,抱歉抱歉...汗!!!
应该是
var str="HTML语句";
str=str.replace(/<[^<>]*>/g,"");
lip009 2006-08-09
  • 打赏
  • 举报
回复
我倒...定义写多了
var str="HTML语句";
str=str.replace(/<(.*)>.*<\/\1>|<(.*) \/>/g,"");
lip009 2006-08-09
  • 打赏
  • 举报
回复
String str="HTML语句";
str=str.replace(/<(.*)>.*<\/\1>|<(.*) \/>/g,"");
netset 2006-08-09
  • 打赏
  • 举报
回复
Function stripHTML(strHTML)
Dim objRegExp,strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
'strOutput = objRegExp.Replace(strHTML,"")
strOutput = Replace(strOutput, "<","<")
strOutput = Replace(strOutput, ">",">")
stripHTML = strOutput
Set objRegExp = Nothing
End Function
joist 2006-06-18
  • 打赏
  • 举报
回复
study
王建宁 2006-06-18
  • 打赏
  • 举报
回复
学习
hetoo 2006-06-10
  • 打赏
  • 举报
回复
<[^<>]+>
这个好像过滤不掉<font color="#ffffff"></font>之类的
cqq 2006-06-10
  • 打赏
  • 举报
回复
[^<>] 就是匹配除了 < 和 > 以外的, 呵呵 , 你可以看看正则表达式

我也是刚看,挺有意思的。
hetoo 2006-06-10
  • 打赏
  • 举报
回复
好的
谢谢
和 <[^<>]+>有哪些区别
不好意思
对正则我不太懂
cqq 2006-06-10
  • 打赏
  • 举报
回复
. 就是匹配换行以外的字符
+ 就是匹配1次或者多次
? 就是非贪婪的

大体意思就是 匹配 两边是尖括号的<> ,中间是一个或者多个字符的,

但是这样的话 <hello> 这样的也会被匹配上。
hetoo 2006-06-10
  • 打赏
  • 举报
回复
cqq(脑电波)

能否给解释一下

<.+?>
cqq 2006-06-10
  • 打赏
  • 举报
回复
Set regEx = New RegExp
regEx.Pattern = "<.+?>"
regEx.IgnoreCase = True
regEx.Global = True

sResult = regEx.replace(s,"")

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧