tags:

views:

50

answers:

1

Hi, I have a string:

By Chris Sheridan MADRID, Spain -- Rudy Fernandez is not returning calls from Portland Trail Blazers coach Nate McMillan and was fined $25000 by the NBA on ... var make_url = 'http://goog.com/Escape_Space_Link';

My question is how do I use regex and php's preg_replace to remove the entire var make_url = 'http://goog.com/Escape_Space_Link'

Please note that http://goog.com/Escape_Space_Link may change, but it's always a url

Thank you!

+1  A: 

If it's always the same string you want to remove, use str_replace instead.

$string = str_replace("var make_url = 'http://goog.com/Escape_Space_Link'", "", $inputString);

If it's always "var make_url = 'http://someurl';", you can use this preg_replace to remove the url:

$string = preg_replace("/var make_url = 'http:\/\/.+';/", "", $inputString);
Leon
From the OP - `Please note that http://goog.com/Escape_Space_Link may change, but it's always a url`
Peter Ajtai