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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.