Skip to content

escapeRegExp

对字符串 str 中的正则元字符进行转义,返回转义后的字符串。

Added in v0.0.2

Usage

ts
import { escapeRegExp } from 'parsnip-kit'

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

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

API

Arguments

ArgTypeOptionalDefaultDescription
strstringfalseundefined待转义的字符串

Returns

Type
string