Php code for regular expression matching html tags

Source: Internet
Author: User
Regular expression
<(\ S *?) [^>] *> .*? </\ 1> | <.*? />
Match <Html> hello
Mismatch Abc | 123 |

 

Regular expression
^ [^ <> '~! /@\#}$ %:;) (_ ^ {& * = | '+] + $
Match This is a test
Mismatch <Href = | <br> | That's it

 

Regular expression
& Lt ;! --.*? -- & Gt;
Match & Lt ;! -- & Lt; h1 & gt; this text has been removed & lt;/h1 & gt; -- & gt; | & lt ;! -- Yada -- & gt;
Mismatch & Lt; h1 & gt; this text has not been removed & lt;/h1 & gt;

 

Regular expression
(\ [(\ W +) \ s * ([\ w] *) = ('| & quot ;)? ([A-zA-Z0-9 |: | \/| = |-|. | \? | & Amp;] *) (\ 5 )?) * \]) ([A-zA-Z0-9 |: | \/| = |-|. | \? | & Amp; | \ s] +) (\ [\/\ 2 \])
Match [Link url = & quot; http://www.domain.com/file.extension? Getvar = value & amp; secondvar = value & quot;] Link [/li
Mismatch [A] whatever [/B] | [a var1 = something var2 = somethingelse] whatever [/a] | [a] whatever [a]

 

Regular expression
Href = [\ "\ '] (http: \/| \. \/| \/)? \ W + (\. \ w +) * (\/\ w + (\. \ w + )?) * (\/| \? \ W * = \ w * (& \ w * = \ w *)*)? [\ "\ ']
Match Href = "www.yahoo.com" | href = "http: // localhost/blah/" | href = "eek"
Mismatch Href = "" | href = eek | href = "bad example"

 

Regular expression
& Quot; ([^ & quot;] (? : \. | [^ \ & Quot;] *) & quot;
Match & Quot; This is a \ & quot; string \ & quot;. & quot;
Mismatch & Quot; This is a \ & quot; string \ & quot ;.

 

Regular expression
(? I: on (blur | c (hange | lick) | dblclick | focus | keypress | (key | mouse) (down | up) | (un )? Load | mouse (move | o (ut | ver) | reset | s (elect | ubmit )))
Match
 
Onclick | onsubmit | onmouseover
Mismatch Click | onandon | mickeymouse

 

Regular expression
(? S )/\*.*\*/
Match /* ........../|/* Imagine lots of lines here */
Mismatch */Malformed opening tag */|/* malformed closing tag /*

 

Regular expression
<(\ S *?) [^>] *> .*? </\ 1> | <.*? />
Match <Html> hello
Mismatch Abc | 123 |

 

Regular expression
\ XA9
Match ©
Mismatch Anything

 

Regular expression
Src [^ & gt;] * [^/]. (? : Jpg | bmp | gif )(? : \ & Quot; | \')
Match Src = & quot; ../images/image.jpg & quot; | src = & quot; yun_qi_img/image.jpg & quot; | src = 'd: \ w
Mismatch Src = & quot; ../images/image. tif & quot; | src = & quot; cid: value & quot;

 

Regular expression
/\ * [\ D \ D] *? \*/
Match /* My comment */|/* my multiline comment */|/* my nested comment */
Mismatch */Anything here/* | anything between 2 seperate comments | \**\

 

Regular expression
<[A-zA-Z] + (\ s + [a-zA-Z] + \ s * = \ s * ("([^"] *) "| '([^'] *) ') * \ s */>
Match
Mismatch |

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.