开发者

Regular expression for string that starts with 'http://'

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+)?)?)?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜