Reputation: 4357
I want to remove all occurrences of URL [full path, query string] from the text in Python. Any suggestions on how to do this? I am new to regex!
http://example.com/url/?x=data
This whole URL should be removed! Thanks
Upvotes: 1
Views: 4572
Reputation: 15
<?php
preg_match_all('/<a.*?href=".*?">(.*?)<[\/]a>/', $content,$arr);
$new_content = str_replace($arr[0], $arr[1], $content);
echo $new_content;
?>
Upvotes: -1
Reputation: 20175
This previous question will get you off to a good start to match the URL, (ie. RegExLib.com) then its just a matter of the removal
Upvotes: 1
Reputation: 4337
This is definitely a non-trivial task assuming you want to remove any valid URL. I'd take a look at the Regex Lib page on the topic.
Upvotes: 1