I'm very new at regular expressions: I want to preg_match all elements in a html dom, that has a data-editable attribute. All other attributes of those elements should be matched also, so i can reuse them later:
<div class="teaser" id="teaser" data-editable><p>Content</p></div>
After matching i want those elements with data-editable attribute to have specific css classes and add another element inside. So only block-level parents should be matched.
<div class="teaser editable" id="teaser"><button>edit</button><p>Content</p></div>
Here's what i've got:
<(div|p).*(data-editable).[^>]+>(.*?)<\/\1>
I know, i'm totally wrong with that - this one matches also elements that does not have that data-editable attribute set because of that .+
inside. But how to match the different attributes without losing their values?