I am not that good in writing regular expressions so I am asking for help.
I have html string of my page. I want convert html string to Google AMP compatible page. In which I want to replace some custom html tags.
<define:dos> This string explains DOS.</define:dos>
And output should be only This string explains DOS.
There are several strings in my html string starting with <define:
I tried to remove them by writing separate preg_replace
for each tag which works as expected:
$html = preg_replace('#<define:wlan>#i', '', $html);
$html = preg_replace('#<define:wifi>#i', '', $html);
$html = preg_replace('#<define:dos>#i', '', $html);
And so on
I tried something as follows but didn't work :(
$html = preg_replace('#\<define[^\]>*\](.*?)\</define\>#m', "$1", $html);
I want generic solution for this. Please help.
Thank you in advance.
You can use
<(define:[^>]+>)(.*?)<\/\1
and replace with the second captured group, \2
.