1.1.2 • Published 2 years ago

@hugoalh/regular-expression-constructor v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Regular Expression Constructor (NodeJS)

RegularExpressionConstructor.NodeJS

NodeJS License GitHub Stars GitHub Contributors GitHub Issues GitHub Pull Requests GitHub Discussions CodeFactor Grade

ReleasesLatest (GitHub Latest Release Date)Pre (GitHub Latest Pre-Release Date)
GitHub GitHub Total DownloadsGitHub Latest Release VersionGitHub Latest Pre-Release Version
NPM NPM Total DownloadsNPM Latest Release VersionNPM Latest Pre-Release Version

📝 Description

A NodeJS module to help for constructing regular expression.

📚 Documentation

Getting Started

Install

  • NodeJS >= v10.13.0
npm install @hugoalh/regular-expression-constructor

Use

CommonJS
const regularExpressionConstructor = require("@hugoalh/regular-expression-constructor");
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;
  indices: boolean = false;
  multipleLine: boolean = false;
  sticky: boolean = false;
}

Example

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

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