RegExp.ts overview
Constructors and pre-built RegExp instances backed by patterns from | 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 withfromRegExpString; the bundled instances are flag-free.
Common tasks
- Construct from a pattern string:
fromRegExpString - Pre-built instances:
lineBreak,universalPathSep,semVer,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
Exports Grouped by Category
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
declare const fromRegExpString: (flags?: string) => (s: string) => Type
Instances
A RegExp matching an entire e-mail address. Uses MRegExpString.email anchored to a full line.
Signature
declare const email: RegExp
lineBreak
A RegExp matching a line break (CRLF, CR or LF). No g flag.
Signature
declare const lineBreak: RegExp
semVer
A RegExp matching an entire SemVer string of the form X.Y.Z. Uses MRegExpString.semVer anchored to a full line.
Signature
declare const semVer: RegExp
universalPathSep
A RegExp matching a path separator on any platform (/ or \).
Signature
declare const universalPathSep: RegExp
Models
Type (type alias)
Type on which this module’s functions operate.
Signature
type Type = RegExp