Hi guys just like in the title - I need regular expression that will match anything that starts with 'http://'
@Gordon, it will do what the OP asked.
klausbyskov
2010-10-25 11:06:48
+1
A:
Is that really what you want?
This will match everything up to the first whitespace: ^http://[^\s]*
Nev Stokes
2010-10-25 10:52:41
Strictly speaking, the OP doesn't explicitly mention that it's a URI - he just wants to match *anything* that starts with 'http://'
Nev Stokes
2010-10-25 11:09:04
+2
A:
Why not just look to see if the first 7 characters are "http://"
substr($url, 0, 7) == "http://"
No need for regexps here.
Paul
2010-10-25 10:56:35
Agreed, but the OP asks for matches for anything that starts with 'http://', not for matches of http:// anywhere in the string.
Paul
2010-10-25 11:03:45
Strpos will go off looking in the rest of the string too, so will be slower in non-matching cases :) We need the OP to tell us what's really needed.
Paul
2010-10-25 11:08:19
+1
A:
So basicly, you want to match a URL in a string?
http://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?
Ruel
2010-10-25 10:56:56