RegExp overview
Constructors and pre-built RegExp instances backed by patterns from {@link “./RegExpString.js” | MRegExpString}.
Mental model
- This module materializes the string patterns from
MRegExpStringas actualRegExpobjects. - When you need a regex with custom flags (e.g. the
gflag), build it with {@link fromRegExpString}; the bundled instances are flag-free.
Common tasks
- Construct from a pattern string: {@link fromRegExpString}
- Pre-built instances: {@link lineBreak}, {@link universalPathSep}, {@link semVer}, {@link email}
Quickstart
Example (Match a SemVer string)
import * as MRegExp from "@parischap/effect-lib/MRegExp"
console.log(MRegExp.semVer.test("1.2.3")) // true
console.log(MRegExp.semVer.test("1.2")) // false
Table of contents
Constructors
fromRegExpString
Builds a RegExp from a pattern string, optionally with flags.
Example (Build a regex with the i flag)
import { pipe } from "effect"
import * as MRegExp from "@parischap/effect-lib/MRegExp"
const ci = pipe("hello", MRegExp.fromRegExpString("i"))
console.log(ci.test("HELLO")) // true
Signature
export declare const fromRegExpString: (flags?: string) => (s: string) => RegExp
Instances
A RegExp matching an entire e-mail address. Uses {@link MRegExpString.email} anchored to a full line.
Signature
export declare const email: RegExp
lineBreak
A RegExp matching a line break (CRLF, CR or LF). No g flag.
Signature
export declare const lineBreak: RegExp
semVer
A RegExp matching an entire SemVer string of the form X.Y.Z. Uses {@link MRegExpString.semVer} anchored to a full line.
Signature
export declare const semVer: RegExp
universalPathSep
A RegExp matching a path separator on any platform (/ or \).
Signature
export declare const universalPathSep: RegExp