I want to remove all occurrences of URL [full path, query string] from the text in Python. Any suggestions on 开发者_Go百科how to do this? I am new to regex!
http://example.com/url/?x=data
This whole URL should be removed! Thanks
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.
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
URL remove Example
<?php
preg_match_all('/<a.*?href=".*?">(.*?)<[\/]a>/', $content,$arr);
$new_content = str_replace($arr[0], $arr[1], $content);
echo $new_content;
?>
精彩评论