Regex Escape

Enter a string and get a version with regex metacharacters escaped so it can be used literally inside a RegExp.

Escape for regex

How it works

We escape [ ] ( ) { } * + ? . \ ^ $ | and backslash so the result matches the literal string.

When to use it

Use when building a regex from user input or a variable string.

Frequently asked questions

Which characters?

We escape the JavaScript regex metacharacters so the string is treated literally.