Skip to content

escapeRegExp

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

Import:

import { escapeRegExp } from 'obsidian-dev-utils/reg-exp';

Signature:

function escapeRegExp(str: string): string

Parameters:

ParameterTypeDescription
strstringThe string to escape.

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