Skip to content

escapeRegExp

Escapes the regular expression metacharacters in string str and returns the escaped string.

Added in v0.0.2

Usage

ts
import { escapeRegExp } from 'parsnip-kit'

escapeRegExp('hello world')
// 'hello world'

escapeRegExp('${name}')
// '\\$\\{name\\}'

API

Arguments

ArgTypeOptionalDefaultDescription
strstringfalseundefinedThe string to escape

Returns

Type
string