[英]php remove curly braces and content inside retrieve remaining
想要删除大括号内的 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
使用正则表达式,
$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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.