There is HTML:
<div id="attachment_21727" class="someclass">
<img alt="text" src="url" />
<p class="wp-caption-text">Text</p>
</div>
I need to replace div
to another tag. So i need to find this div
,find content in it, and replace.
attachment_21727 - relative as attachment_{number}
So i have a function PHP:
$pattern = "/<div id=\"attachment_(.*?)\" (.*?)>(.*?)<\/div>/i";
$replacement = '<figure>$3</figure>';
$content = preg_replace($pattern, $replacement, $content);
But not working...Any ideas?