2

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!

3
  • 1
    Will the link always be the same? and will it always be at the end of the string? Commented Aug 20, 2010 at 7:41
  • The link will keep changing, and it's not always at the end of the string. Thanks! Commented Aug 21, 2010 at 7:57
  • How do you get that string in the first place? It looks like someone run strip_tags() on some HTML. In such case, it'd be better to run an HTML parser. Commented Aug 24, 2010 at 12:00

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.