Patrick
Patrick

Reputation: 4905

php preg_replace url

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!

Upvotes: 2

Views: 1003

Answers (1)

Leon
Leon

Reputation: 869

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);

Upvotes: 1

Related Questions