Skip to content

escapeRegExp

Escapes special characters in a string to safely use it within a regular expression.

Import:

import { escapeRegExp } from '@mnaoumov/typescript-lib/reg-exp';

Signature:

function escapeRegExp($string: string): string

Parameters:

Parameter Type Description
$string string

Returns: string — The escaped string with special characters prefixed with a backslash.