我有以下字符串
Hi this string is to @removeStart be modified by @removeEnd function
我想删除@removeStart
和@removeEnd
重合的字符串部分以及上面字符串中的这两个标记
答案 0 :(得分:2)
试试这个
$str = 'Hi this string is to @removeStart be modified by @removeEnd function';
echo preg_replace('/@removeStart (.*) @removeEnd/','',$str);
答案 1 :(得分:1)
(@\b\w+)
<?php
$str="Hi this string is to @removeStart be modified by @removeEnd function";
echo preg_replace('(@\b\w+)','',$str);
?>
Hi this string is to be modified by function