import { Meta } from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/functional-basic/Functions/escapeExp - Escape special RegExp characters'/>

# `escapeExp`

A utility that escapes all special regular expression characters in a string (`.` `*` `+` `?` `^` `$` `{` `}` `(` `)` `|` `[` `]` `\` `/`), so it can be safely used inside a `RegExp`.

Useful when a string comes from user input or an external source and may contain characters that have special meaning in regular expressions.

**Parameters:**
- `value: string` — The string to escape.

**Returns:**
`string` — A string with all special regex characters escaped, safe to use inside a `RegExp`.

```typescript
import { escapeExp } from '@dxtmisha/functional-basic'

// Escaping characters
console.log(escapeExp('user.name[0]')) // 'user\\.name\\[0\\]'
console.log(escapeExp('price $10.00')) // 'price \\$10\\.00'

// Safe usage inside RegExp
const regex = new RegExp(escapeExp('user.name[0]'))
regex.test('user.name[0]') // true
regex.test('userXname0')   // false
```
