PHP: Regular Expression to get a URL from a string
Posted
by Matthew Iselin
on Stack Overflow
See other posts from Stack Overflow
or by Matthew Iselin
Published on 2010-04-27T11:45:18Z
Indexed on
2010/04/27
11:53 UTC
Read the original article
Hit count: 227
I'm working on some PHP code which takes input from various sources and needs to find the URLs and save them somewhere. The kind of input that needs to be handled is as follows:
http://www.youtube.com/watch?v=IY2j_GPIqRA
Try google: http://google.com! (note exclamation mark is not part of the URL)
Is http://somesite.com/ down for anyone else?
Output:
http://www.youtube.com/watch?v=IY2j_GPIqRA
http://google.com
http://somesite.com/
I've already borrowed one regular expression from the internet which works, but unfortunately wipes the query string out - not good!
Any help putting together a regular expression, or perhaps another solution to this problem, would be appreciated.
© Stack Overflow or respective owner