0

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

ssrp
  • 1,126
  • 5
  • 17
  • 35

2 Answers2

2

Try this

$str = 'Hi this string is to @removeStart be modified by @removeEnd function';
echo preg_replace('/@removeStart (.*) @removeEnd/','',$str);
Rohit Subedi
  • 560
  • 3
  • 13
1

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
Jaykumar Patel
  • 26,836
  • 12
  • 74
  • 76