veffect
Version:
powerful TypeScript validation library built on the robust foundation of Effect combining exceptional type safety, high performance, and developer experience. Taking inspiration from Effect's functional principles, VEffect delivers a balanced approach tha
18 lines (16 loc) • 414 B
text/typescript
/**
* This module provides utility functions for working with RegExp in TypeScript.
*
* @since 2.0.0
*/
/**
* Escapes special characters in a regular expression pattern.
*
* @example
* import * as RegExp from "effect/RegExp"
*
* assert.deepStrictEqual(RegExp.escape("a*b"), "a\\*b")
*
* @since 2.0.0
*/
export const escape = (string: string): string => string.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&")