New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

json-to-regex

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-to-regex

Utility library for converting JSON-stored regexes (strings) to actual regexes.

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
282
decreased by-4.73%
Maintainers
1
Weekly downloads
 
Created
Source

This library is a simple wrapper around new RegExp(pattern, options) primarily intended for use with regexes from JSON config files.

Installation

npm install json-to-regex

Quick Start

const jsonToRegex = require('json-to-regex');

const regex = jsonToRegex('foo.*bar$');
const moreRegexes = [ 'ab?c', 'de+\\D' ].map(jsonToRegex);
const caseInsensitiveRegex = jsonToRegex([ '^hello', 'i' ]);

Usage

jsonToRegex(value)

Passing in a string value will result in the string being converted to a regex, e.g. '^hello.*!$' => /^hello.*!$/. To set regex options such as case insensitivity, pass in an array where the first element is the regex string and the second element is the options, e.g. ['^hello.*!$', 'i'] => /^hello.*!$/i

FAQs

Package last updated on 18 May 2017

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