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 🙏

© 2025 – Pkg Stats / Ryan Hefner

reggie-docs

v0.0.7

Published

This package will take a Template Literal, remove comments, and generate a RegEx-ready string or regex for use.

Downloads

27

Readme

Reggie-Docs

About

This package will take a Template Literal, remove comments, and generate, either:

  • reggie.create creates RegEx-ready String.
  • reggie.generate generates RegExp Object.

Version

0.0.7

Installation

npm install reggie-docs

Usage

Options

setFlag

reggie.setFlag(flag) sets the default flag used for reggie.generate).

  • Takes a string.

create

reggie.create(templateLiteral) returns a RegEx-ready String.

  • Takes a template literal.

reggie.create`a tagged template literal` returns a Regex-ready String.

  • Tagged with a template literal.

generate

reggie.generate(templateLiteral, [flags = 'gm'] returns a RegExp Object.

  • Takes a template literal.
  • Optional flags: defaults to gm

reggie.generate`a tagged template literal` returns a RegExp Object.

  • Tagged with a template literal.
  • Cannot pass flag with this method; use reggie.setFlag before reggie.generate.

Examples


const Reggie = require('reggie-docs');
const reggie = new Reggie();

let results = {};

// /^[\s]*(.*?)[\s]*$/
const code0001 = `
  ^       // Beginning of line
  [\s]*  // Zero or more whitespace

  (.*?)   // Any characters, zero to unlimited,
          //  lazy (as few times as possible, expanding as needed)

  [\s]*  // Zero or more whitespace
  $       // End of line
`;
const patternCheck0001 = '  Test Spaces Before and After   ';

results.code0001 = reggie.create(code0001);
const code0001Exp = reggie.generate(code0001);
results.code0001Test = code0001Exp.exec(patternCheck0001)[1];

results.code0002 = reggie.create`
  ^       // Beginning of line
  [\s]*  // Zero or more whitespace

  (.*?)   // Any characters, zero to unlimited,
          //  lazy (as few times as possible, expanding as needed)

  [\s]*  // Zero or more whitespace
  $       // End of line
`;

results.code0003 = reggie.generate`
  ^       // Beginning of line
  [\s]*  // Zero or more whitespace

  (.*?)   // Any characters, zero to unlimited,
          //  lazy (as few times as possible, expanding as needed)

  [\s]*  // Zero or more whitespace
  $       // End of line
`;

// ^((?<area>[\d]{3})[-][\d]{2}[-][\d]{4})$
const code0004 = `
  ^                   // BOL
  (                   // Group
    (?<area>            // Group-NAMED area
      [\d]{3}            // 3-Digits
    )                   // Group-NAMED-END
    [-]                 // Literal, Dash
    [\d]{2}            //  2-Digits
    [-]                 // Literal, Dash
    [\d]{4}            // 4-Digits
  )                   // Group-END
  $                   // EOL
`;
const patternCheck0004a = '111-22-3333';
const patternCheck0004b = '111-22-aaaa';

results.code0004 = reggie.create(code0004);
const code0004Exp = reggie.generate(code0004);
results.code0004TestAValid = code0006Exp.exec(patternCheck0004a) !== null;
results.code0004TestBValid = code0006Exp.exec(patternCheck0004b) !== null;

// /^(v?\d+\.\d+\.\d+)$/gi
const code0005 = `
  ^       // BOL
  (       // Group
    v?    // Version Optional
    \d+   // Any Digit (at least one)
    \.    //  PERIOD CHARACTER
    \d+   // Any Digit (at least one)
    \.    //  PERIOD CHARACTER
    \d+   // Any Digit (at least one)
  )
  $       // EOL
`;

results.code0005 = reggie.generate(code0005, 'gi');

console.log(results);

To Do

  1. [REQUESTED] Create a way to use this in a build process.
  2. Continue to improve the logic.
  3. Add in error handling.