jyushinx Posted May 9, 2008 Share Posted May 9, 2008 Hi, I currently have code which searches a string for unclosed html tags. It works well except for one glitch. A tag like <br/> will be read as closed. But a tag such as <br /> won't. Clearly there is something up with my regex, but I have no idea as I am clueless with it. Here is the code for finding open tags preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result); Any ideas as to how I can modify the regex to recognize tags as being closed like <br /> Thanks. Link to comment https://forums.phpfreaks.com/topic/104813-identifying-unclosed-html-tags-needs-tweaking/ Share on other sites More sharing options...
effigy Posted May 12, 2008 Share Posted May 12, 2008 Changing (?!/)> to (?<!/)> will enforce that a slash should not proceed the ending bracket. P.S. You may want to trying running the content through tidy instead. Link to comment https://forums.phpfreaks.com/topic/104813-identifying-unclosed-html-tags-needs-tweaking/#findComment-539068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.