8000 GitHub - 418sec/url-regex at 3.1.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

418sec/url-regex

Repository files navigation

url-regex Build Status

Regular expression for matching URLs

Based on this gist by Diego Perini.

Install

$ npm install --save url-regex

Usage

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']

API

urlRegex(options)

Returns a regex for matching URLs.

options.exact

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.

License

MIT © Kevin Mårtensson and Diego Perini

About

Regular expression for matching URLs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.1%
  • TypeScript 2.9%
0