Possible Duplicate:
How to match URIs in text?
What is the best regular expression to check if a string is a valid URL?
I need to extract the URL to a zip file from a string that contains many URLs , using regexp (PHP).
A simple example should be helpful:
Target: extract the url http://en.wikipedia.org/wiki/Kettle.zip
Base string:
/url?q=http://en.wikipedia.org/wiki/Kettle.zip&sa=U&ei=VpnIUP22Js blah /url?q=http://en.wikipedia.org/wiki/Kettle&sa=U&ei=VpnIUP22Js blah /url?q=http://en.wikipedia.org/wiki/Kettle.rar&sa=U&ei=VpnIUP22Js
Update; lets say the base string is
href="http://en.wikipedia.org/wiki/Kettle.zip">Some text /a>Some other text here a href="http://google.com/wiki/Kettle"> /a>
i need to extract the http://en.wikipedia.org/wiki/Kettle.zip
any method is ok...regex or not.