mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-30 18:23:22 +03:00
558 B
558 B
escapeRegExp
Escapes the RegExp special characters "^"
, "$"
, "\\"
, "."
, "\*"
, "+"
, "?"
, "("
, ")"
, "["
, "]"
, "{"
, "}"
, and "|"
in str
.
Signature
function escapeRegExp(str: string): string;
Parameters
str
(string
): The string to escape.
Returns
(string
): The escaped string.
Examples
import { escapeRegExp } from 'es-toolkit/string';
escapeRegExp('[es-toolkit](https://es-toolkit.slash.page/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.slash\.page/\)'