1.1.2 • Published 2 years ago
@hugoalh/regular-expression-constructor v1.1.2
Regular Expression Constructor (NodeJS)
RegularExpressionConstructor.NodeJS
Releases | Latest () | Pre () |
---|---|---|
📝 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