想删除包含大括号的大括号内的php字符串的特定文本,它应该删除....
{page:header}
this text should not be removed
{menu_list:menu_list_2}
this text should not be removed
{page:footer}
想要删除大括号内的文字以及花括号......
this text should not be removed
this text should not be removed
答案 0 :(得分:0)
使用正则表达式,
$text='{page:header}
this text should not be removed
{menu_list:menu_list_2}
this text should not be removed
{page:footer}'
$data = preg_replace("/\{[^}]+\}/", "", $text);
print_r($data); // answer will be as follow
this text should not be removed
this text should not be removed