Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Latest commit

 

History

History
24 lines (17 loc) · 459 Bytes

regexp_escape.md

File metadata and controls

24 lines (17 loc) · 459 Bytes

regexp/regexpEscape

Escapes the a string of any special regexp characters.

function regexpEscape(str: string): string

Args

str:string
The string to escape.

Returns

The string with special regexp characters escaped.

Examples

import { regexpEscape } from 'utils/regexp';

console.log(regexpEscape('(foo)'));    // Outputs: '\(foo\)'
console.log(regexpEscape('foo$bar^')); // Outputs: 'foo\$bar\^'