加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式匹配HTML标签或标记

发布时间:2020-12-14 01:22:09 所属栏目:百科 来源:网络整理
导读:正则表达式 (S*?) [^]*.*?/1|.*? / 匹配 htmlhello/html|aabcd/a 不匹配 abc|123|htmlddd 正则表达式 ^[^`~!/@#}$%:;)(_^{*=|'+]+$ 匹配 This is a test 不匹配 href =|br|That's it 正则表达式 lt;!--.*?--gt; 匹配 lt;!-- lt;h1gt;this text has been r
正则表达式
<(S*?) [^>]*>.*?</1>|<.*? />
匹配 <html>hello</html>|<a>abcd</a>
不匹配 abc|123|<html>ddd

正则表达式
^[^<>`~!/@#}$%:;)(_^{&*=|'+]+$
匹配 This is a test
不匹配 <href =|<br>|That's it

正则表达式
&lt;!--.*?--&gt;
匹配 &lt;!-- &lt;h1&gt;this text has been removed&lt;/h1&gt; --&gt;|&lt;!-- yada --&gt;
不匹配 &lt;h1&gt;this text has not been removed&lt;/h1&gt;

正则表达式
([(w+)s*(([w]*)=('|&quot;)?([a-zA-Z0-9|:|/|=|-|.|?|&amp;]*)(5)?)*])([a-zA-Z0-9|:|/|=|-|.|?|&amp;|s]+)([/2])
匹配 [link url=&quot;http://www.domain.com/file.extension?getvar=value&amp;secondvar=value&quot;]Link[/li
不匹配 [a]whatever[/b]|[a var1=something var2=somethingelse]whatever[/a]|[a]whatever[a]

正则表达式
href=["'](http://|./|/)?w+(.w+)*(/w+(.w+)?)*(/|?w*=w*(&w*=w*)*)?["']
匹配 href="www.yahoo.com"|href="http://localhost/blah/"|href="eek"
不匹配 href=""|href=eek|href="bad example"

正则表达式
&quot;([^&quot;](??1.|[^&quot;]*)*)&quot;
匹配 &quot;This is a &;quot;string&;quot;.&quot;
不匹配 &quot;This is a &;quot;string&;quot;.

正则表达式
(?i:on(blur|c(hange|lick)|dblclick|focus|keypress|(key|mouse)(down|up)|(un)?load|mouse(move|o(ut|ver))|reset|s(elect|ubmit)))
匹配
onclick|onsubmit|onmouSEOver
不匹配 click|onandon|mickeymouse

正则表达式
(?s)/*.**/
匹配 /* .................... */|/* imagine lots of lines here */
不匹配 */ malformed opening tag */|/* malformed closing tag /*

正则表达式
<(S*?) [^>]*>.*?</1>|<.*? />
匹配 <html>hello</html>|<a>abcd</a>
不匹配 abc|123|<html>ddd

正则表达式
xA9
匹配 ?
不匹配 anything

正则表达式
src[^&gt;]*[^/].(?:jpg|bmp|gif)(?:&;quot;|')
匹配 src=&quot;../images/image.jpg&quot;|src=&quot;http://domain.com/images/image.jpg&quot;|src='d:w
不匹配 src=&quot;../images/image.tif&quot;|src=&quot;cid:value&quot;

正则表达式
/*[dD]*?*/
匹配 /* my comment */|/* my multiline comment */|/* my nested comment */
不匹配 */ anything here /*|anything between 2 seperate comments|* *

正则表达式
<[a-zA-Z]+(s+[a-zA-Z]+s*=s*("([^"]*)"|'([^']*)'))*s*/>
匹配 <img src="test.gif"/>
不匹配 <img src="test.gif">|<img src="test.gif"a/>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读