Still messing around with regex's, but running into some trouble.
The following should, theoretically, match a div from open to close with all inner HTML:
$pattern = '/(<(DIV)\b[^>]*className[^>]*>)(.*?)(<\/DIV>)/im';
For the most part, it works fine. For example:
<div class="className">This is some content, with <strong>HTML</strong> tags too<div>
preg_match() will return an array with each match:
$match[0] - <div class="className">This is some content, with <strong>HTML</strong> tags too<div>
$match[1] - <div class="className">
$match[2] - div
$match[3] - This is some content, with <strong>HTML</strong> tags too
$match[4] - </div>
Which is expected. But with a quotation mark on the inside:
<div class="className">This is some <a href="page.php">content</a>, with <strong>HTML</strong> tags too<div>
$match[3] becomes:
This is some
I'm pretty sure my expression is the cause. Any suggestions?
Note: I realize this expression will not match nested divs properly, which is fine (wish it could though).