Skip to main content Link Search Menu Expand Document (external link)

RegExp.ts overview

Constructors and pre-built RegExp instances backed by patterns from | MRegExpString.

Mental model

  • This module materializes the string patterns from MRegExpString as actual RegExp objects.
  • When you need a regex with custom flags (e.g. the g flag), build it with fromRegExpString; 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

Source

Instances

email

A RegExp matching an entire e-mail address. Uses MRegExpString.email anchored to a full line.

Signature

declare const email: RegExp

Source

lineBreak

A RegExp matching a line break (CRLF, CR or LF). No g flag.

Signature

declare const lineBreak: RegExp

Source

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

Source

universalPathSep

A RegExp matching a path separator on any platform (/ or \).

Signature

declare const universalPathSep: RegExp

Source

Models

Type (type alias)

Type on which this module’s functions operate.

Signature

type Type = RegExp

Source