如何删除脚本标记,如{audio} {/ audio}或{youtube} {/ youtube}

in my old data it store joomla tags such "{audio}{/audio}" or "{youtube}{/youtube}", and I want to strip these tag.

how I do in php code? if I want leave it content or remove it content.

Please help me, thank you.

You can use a regular expression

$match = "/\{audio\}[^{]*\{\/audio}/";
$replace = "";
$text = "your joomla text which has {audio}something{/audio}";

$output = preg_replace($match, $replace, $text);

This method removes any text that is in between {audio}{/audio} tags, if that's not what you want change

$match = "/\{audio\}([^{]*)\{\/audio}/";
$replace = "\\$0";

which will leave the content in the middle back in the output text.

Compared to regular expression replace function str_replace() is a lot faster.

$text = str_replace("{audio}", "", $text);
$text = str_replace("{\/audio}", "", $text);