Regular Expression Constructor (NodeJS)

RegularExpressionConstructor.NodeJS
GitHub Contributors
GitHub Issues
GitHub Pull Requests
GitHub Discussions
GitHub Stars
GitHub Forks
GitHub Languages
CodeFactor Grade
LGTM Alerts
LGTM Grade

License

Release Latest (GitHub Latest Release Date) Pre (GitHub Latest Pre-Release Date)
GitHub GitHub Total Downloads GitHub Latest Release Version GitHub Latest Pre-Release Version
NPM NPM Total Downloads NPM Latest Release Version NPM Latest Pre-Release Version

📝 Description

A NodeJS module to help for constructing regular expression.

📚 Documentation

Getting Started

Install

  • NodeJS >= v14.15.0
  • NPM >= v6.14.8
npm install @hugoalh/regular-expression-constructor

Use In CommonJS

const regularExpressionConstructor = require("@hugoalh/regular-expression-constructor");

Use In ModuleJS

import regularExpressionConstructor from "@hugoalh/regular-expression-constructor";

API

Function

regularExpressionConstructor(
  pattern: string,
  flags?: (RegularExpressionConstructorFlags|string) = {}
): RegExp

interface RegularExpressionConstructorFlags {
  boundary?: boolean = false,// Add word boundary assertions at the start and end of the pattern.
  caseInsensitive?: boolean = false,
  exactly?: boolean = false,// Add begin and end line assertions at the start and end of the pattern.
  global?: boolean = false,
  multipleLine?: boolean = false,
  sticky?: boolean = false
}

Example

regularExpressionConstructor("fo+", "bi");
//=> /\b(?:fo+)\b/iu

regularExpressionConstructor("fo+", "eg");
//=> /^(?:fo+)$/gu

GitHub

View Github