如何从php [duplicate]中删除String中的特定部分

This question already has an answer here:

I have the following String Hi this string is to @removeStart be modified by @removeEnd function

And I want to remove the string part coincides by @removeStart and @removeEnd and these two tags from the above string

</div>

Try this

$str = 'Hi this string is to @removeStart be modified by @removeEnd function';
echo preg_replace('/@removeStart (.*) @removeEnd/','',$str);

Check this Demo Code Viper

Pattern Check

(@\b\w+)

PHP

<?php

    $str="Hi this string is to @removeStart be modified by @removeEnd function";

    echo preg_replace('(@\b\w+)','',$str);

?>

Result

Hi this string is to be modified by function