I just checked this post (after two years). It might be you got the answer, but for those who are beginners, you can use a regular expression to strip every type of URL or query string
(https|http|ftp)\:\/\/|([a-z0-9A-Z]+\.[a-z0-9A-Z]+\.[a-zA-Z]{2,4})|([a-z0-9A-Z]+\.[a-zA-Z]{2,4})|\?([a-zA-Z0-9]+[\&\=\#a-z]+)
It will strip every type of URLs. Take a look at the following list. I used a different type of domains for those who want to ask "will it strip .us, .in, .pk, etc.? type of domains or not.
- ftp://www.web.com
- web.net
- www.website.info
- website.us
- web.ws?query=true
- www.web.biz?query=true
- ftp://web.in?query=true
- media.google.com
- ns.google.pk
- ww1.smart.au
- www3.smart.br
- w1.smart.so
- ?ques==two&t=p
- http://website.info?ques==two&t=p
- https://www.weborwebsite.com
Working Example (tested in PHP5+, Apache2+):
$str = "ftp://www.web.com, web.net, www.website.info, website.us, web.ws?query=true, www.web.biz?query=true, ftp://web.in?query=true, media.google.com hello world, working more with ns ns.google.pk or ww1.smart.au and www3.smart.br w1.smart.so ?ques==two&t=p http://website.info?ques==two&t=p https://www.weborwebsite.com and ftp://www.hotmail.br";
echo preg_replace("/(https|http|ftp)\:\/\/|([a-z0-9A-Z]+\.[a-z0-9A-Z]+\.[a-zA-Z]{2,4})|([a-z0-9A-Z]+\.[a-zA-Z]{2,4})|\?([a-zA-Z0-9]+[\&\=\#a-z]+)/i", "", $str);
it will return
, , , , , , , hello world, working more with ns or and and