Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

url-regex

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

url-regex

Regular expression for matching URLs

  • 2.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
328K
decreased by-4.93%
Maintainers
1
Weekly downloads
 
Created

What is url-regex?

The url-regex npm package is a utility for matching URLs in strings using regular expressions. It can be used to find and extract URLs from text, validate URLs, and more.

What are url-regex's main functionalities?

Match URLs in a string

This feature allows you to find and extract all URLs present in a given string.

const urlRegex = require('url-regex');
const text = 'Check out this link: https://example.com and this one: http://example.org';
const urls = text.match(urlRegex());
console.log(urls); // ['https://example.com', 'http://example.org']

Validate a URL

This feature allows you to validate if a given string is a valid URL.

const urlRegex = require('url-regex');
const isValidUrl = urlRegex({ exact: true }).test('https://example.com');
console.log(isValidUrl); // true

Match URLs with specific protocols

This feature allows you to match URLs with specific protocols, such as 'https' or 'ftp'.

const urlRegex = require('url-regex');
const text = 'Visit our site at https://example.com or our FTP server at ftp://example.org';
const urls = text.match(urlRegex({ protocols: ['https'] }));
console.log(urls); // ['https://example.com']

Other packages similar to url-regex

Keywords

FAQs

Package last updated on 01 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc