Should be an easy pattern match and replace, but I want to be able to remove a full URL from text.
So:
'You gotta love it! http://www.youtube.com/watch?v=0i_bkLbf3EI check it out!!!'
Becomes:
'You gotta love it! check it out!!!'
Any ideas?
Step 1: Find a regular expression that matches URLs
http://mathiasbynens.be/demo/url-regex
Seems like the last one (@diegoperini) is the best, but it weighs in at 502 characters.
Step 2: Replace any matches of that regex with the empty string
$output = preg_replace($regex, '', $input);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With