Regex Escaper
Paste any text and get a version with every special character escaped, ready to use inside a regular expression. Switch to unescape to reverse it.
Worked examples
A price in brackets
cost (£5.00)
cost \(£5\.00\)
The brackets and the full stop are escaped.
Undo the escapes
a\.b\*c
a.b*c
The backslashes in front of special characters are removed.
About Regex Escaper
This tool escapes text for use in a regular expression. Characters such as the full stop, brackets, plus, star and question mark have special meanings, so each one gets a backslash and the pattern matches the text itself.
Choose whether to escape the slash and hyphen too, which helps when the pattern sits between slashes or inside a character class. A string option doubles the backslashes for patterns written inside quotes. Switch to unescape to remove the backslashes again.
How to use Regex Escaper
- Paste the text you want to match literally.
- Choose escape or unescape, and the extra options if you need them.
- Copy the result into your pattern.
Common uses
- Searching for a price, address or file path without special meanings
- Building a pattern from user input
- Putting a literal string inside a larger regular expression
- Reading an escaped pattern back as plain text
Frequently asked questions
Which characters are escaped?
The backslash, caret, dollar sign, full stop, vertical bar, question mark, star, plus, round brackets, square brackets and curly brackets. The slash and hyphen are added when that option is ticked.
When do I need the string option?
When the pattern will be written inside a quoted string, as in many languages, where every backslash itself has to be doubled to survive.
Are letters and numbers escaped?
No. Escaping a letter can give it a special meaning, such as \d for a digit, so letters and digits are never touched.
Does unescape reverse everything?
It removes a backslash that sits in front of a special character. Other backslash sequences, such as \n, are left alone.