npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

regexsolver

v1.0.4

Published

RegexSolver allows you to manipulate regular expressions as sets, enabling operations such as intersection, union, and subtraction.

Downloads

49

Readme

RegexSolver Node.js API Client

Homepage | Online Demo | Documentation | Developer Console

This repository contains the source code of the Node.js library for RegexSolver API.

RegexSolver is a powerful regular expression manipulation toolkit, that gives you the power to manipulate regex as if they were sets.

Installation

npm install regexsolver

Usage

In order to use the library you need to generate an API Token on our Developer Console.

import { RegexSolver, Term } from 'regexsolver';

RegexSolver.initialize("YOUR TOKEN HERE");

const term1 = Term.regex("(abc|de|fg){2,}");
const term2 = Term.regex("de.*");
const term3 = Term.regex(".*abc");

const term4 = Term.regex(".+(abc|de).+");

term1.intersection(term2, term3)
    .then(result => result.subtraction(term4))
    .then(result => console.log(result.toString()));

Features

Intersection

Request

Compute the intersection of the provided terms and return the resulting term.

The maximum number of terms is currently limited to 10.

const term1 = Term.regex("(abc|de){2}");
const term2 = Term.regex("de.*");
const term3 = Term.regex(".*abc");

term1.intersection(term2, term3).then(result => {
  console.log(result.toString());
});

Response

regex=deabc

Union

Compute the union of the provided terms and return the resulting term.

The maximum number of terms is currently limited to 10.

Request

const term1 = Term.regex("abc");
const term2 = Term.regex("de");
const term3 = Term.regex("fghi");

term1.union(term2, term3).then(result => {
  console.log(result.toString());
});

Response

regex=(abc|de|fghi)

Subtraction / Difference

Compute the first term minus the second and return the resulting term.

Request

const term1 = Term.regex("(abc|de)");
const term2 = Term.regex("de");

term1.subtraction(term2).then(result => {
  console.log(result.toString());
});

Response

regex=abc

Equivalence

Analyze if the two provided terms are equivalent.

Request

const term1 = Term.regex("(abc|de)");
const term2 = Term.regex("(abc|de)*");

term1.isEquivalentTo(term2).then(result => {
  console.log(result);
});

Response

false

Subset

Analyze if the second term is a subset of the first.

Request

const term1 = Term.regex("de");
const term2 = Term.regex("(abc|de)");

term1.isSubsetOf(term2).then(result => {
  console.log(result);
});

Response

true

Details

Compute the details of the provided term.

The computed details are:

  • Cardinality: the number of possible values.
  • Length: the minimum and maximum length of possible values.
  • Empty: true if is an empty set (does not contain any value), false otherwise.
  • Total: true if is a total set (contains all values), false otherwise.

Request

const term = Term.regex("(abc|de)");

term.getDetails().then(details => {
  console.log(details.toString());
});

Response

Details[cardinality=Integer(2), length=Length[minimum=2, maximum=3], empty=false, total=false]

Generate Strings

Generate the given number of strings that can be matched by the provided term.

The maximum number of strings to generate is currently limited to 200.

Request

const term = Term.regex("(abc|de){2}");

term.generateStrings(3).then(result => {
  console.log(result);
});

Response

[ 'deabc', 'abcde', 'dede' ]