查找用户定义的开始和结束标记

查找用户定义的开始和结束标记

问题描述:

我怎么能找到打开{表}之间的所有和结束标记{/表}之间的所有 如查找用户定义的开始和结束标记

{table} This is <strong>table</strong> {/table} 

我希望所有的html标签应在被删除{表}标签

preg_replace_callback('@{table}(.*?){/table}@', 
    function ($mat) { return strip_tags($mat[0]); }, $s); 

对于像

aa {table} This is <strong>table</strong> {/table} kk

这会给

aa {table} This is table {/table} kk
+0

谢谢你解决了我的问题 – user523626 2011-04-11 11:33:47

$input = '{table} This is <strong>table</strong> {/table}'; 
$output = ''; 
preg_match('/\{table\}(.*?)\{\/table\}/', $input, $matches); 

if (!empty($matches[1])) { 
    $output = stripslashes($matches[1]); 
}