I'm trying to use preg_replace to find and remove part of page in CMS.
This is example of code that I would like to have removed:
<dt>
<label for="my_label">My label:</label>
</dt>
<dd>
<select name="my_label" id="my_label">
<option value="0" selected="selected">option 0</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
</dd>
Options can be dynamic, they depend on user settings in profile.
With help from many tips on other questions asked here I was able to make this:
preg_replace('#(?<=<label for="my_label">)(.*?)(?=<\/select>)#ms', '', $html);
It works quite nice but there's one small problem that I cannot seem to resolve - output looks like this:
<dt>
<label for="my_label"></select>
</dd>
Would it be possible to remove it wit some modification to preg_replace that I wrote above? I intentionally posted code with spaces as I think that it's important to reg exp.