Regular expression for matching URLs
Based on this gist by Diego Perini.
$ npm install --save url-regex
var urlRegex = require('url-regex');
urlRegex().test('http://github.com foo bar');
//=> true
urlRegex({exact: true}).test('http://github.com foo bar');
//=> false
urlRegex({exact: true}).test('http://github.com');
//=> true
'foo http://github.com bar //google.com'.match(urlRegex());
//=> ['http://github.com', '//google.com']
Returns a regex for matching URLs.
Type: boolean
Default: false
(Matches any URL in a string)
Only match an exact string.
Useful with RegExp#test
to check if a string is a URL.
MIT © Kevin Mårtensson and Diego Perini