mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-03 01:42:44 +03:00
26 lines
530 B
Markdown
26 lines
530 B
Markdown
|
# escapeRegExp
|
||
|
|
||
|
Escapes the RegExp special characters "^", "$", "\\", ".", "\*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`.
|
||
|
|
||
|
## Signature
|
||
|
|
||
|
```typescript
|
||
|
function escapeRegExp(str: string): string;
|
||
|
```
|
||
|
|
||
|
### Parameters
|
||
|
|
||
|
- `str` (`string`): The string to escape.
|
||
|
|
||
|
### Returns
|
||
|
|
||
|
(`string`): The escaped string.
|
||
|
|
||
|
## Examples
|
||
|
|
||
|
```typescript
|
||
|
import { escapeRegExp } from 'es-toolkit/string';
|
||
|
|
||
|
escapeRegExp('[es-toolkit](https://es-toolkit.slash.page/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.slash\.page/\)'
|
||
|
```
|