Forum Moderators: coopster

Message Too Old, No Replies

regex non matching tags

         

andytwiz

5:56 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



Hi

I wish to modify the following code to return tags that do NOT match

e.g. <b> hjfdhskdfkjsd </a>


$html = "<b>bold text</b><a href=howdy.html>click me</a>";

preg_match_all("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/", $html, $matches);

I thought I'd just ened to try: (<\/^\\2>) adding the ^ before the \\2 referencing the second ( ) but this doesnt seem to work. Any hints?

Cheers

[edited by: coopster at 8:06 pm (utc) on Mar. 30, 2005]
[edit reason] Disabled graphic smile faces for this post [/edit]

coopster

12:31 am on Mar 31, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Pretty big undertaking. Have you considered the Tidy Functions [php.net]?