I need help to make a reg exp. to match these: The goal is to match any html tag that only <br/>
or/and spaces.
<p><br/></p>
<h1><br/></h1>
<p><br/><br/></p>
<span><br/><br/></span>
<b><br/> <br/> </b>
<h2><br/> <br/> </h2>
Try:
preg_match_all('#<([\S]+)[^>]*>(\s*|(<br\s*/>)*)*</\\1>#i', $html, $m);
If you want to strip elements that contain only comments as well as whitespace/ <br/>
, that's going to be a pain, maybe even impossible, using regex alone.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.