I need a regular expression that wi开发者_StackOverflowll match anything that starts with 'http://'.
Just look to see if the first 7 characters are "http://":
substr($url, 0, 7) == "http://"
There isn't any need for regular expressions here.
This will match everything up to the first whitespace: ^http://[^\s]*
This should do it: ^http://.*
So basically, if you want to match a URL in a string, use:
http://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?
精彩评论