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,008
  • 5
  • 16
  • 34

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
  • 562
  • 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
  • 25,525
  • 12
  • 68
  • 75