Regex Escape & Unescape
Need to match a literal string that contains dots, parentheses, or other special characters inside a regex? Paste it here and get a properly escaped version that matches exactly what you typed. You can also reverse the process to recover the original text. Everything runs locally as you type.
How to use the Regex Escape & Unescape
Choose Escape to turn literal text into a regex-safe form, or Unescape to strip the backslashes back out, then type or paste into the input box. The result updates live and Copy output places it on your clipboard. In escape mode every character that has special meaning in a regular expression — . * + ? ^ $ { } ( ) | [ ] \ — is prefixed with a backslash so the engine treats it as an ordinary character.
The Also escape / option additionally escapes forward slashes. You want this when you will paste the result between slash delimiters, as in JavaScript's /pattern/ literal syntax or in tools like sed and Perl that use / to mark the pattern; without delimiters (for example when building a pattern from a string in code) you can leave it off. Unescape mode does the reverse, removing a single backslash before any escaped character so you get back the plain text — useful for reading what a generated or copied pattern actually matches.
It all runs in your browser as you type, so it is instant, works offline, and nothing you paste is sent anywhere.
Why escaping matters in regular expressions
A regular expression is a small language in which certain punctuation characters are operators rather than literal text. A dot means "any character," an asterisk means "zero or more of the preceding," parentheses create groups, square brackets define character classes, and so on. That expressive power is the whole point of regex — but it becomes a hazard the moment you want to match a string that happens to contain those same characters literally. Searching for the text example.com with an unescaped dot will also match exampleXcom, and a price like $19.99 contains a dollar sign that means "end of line" and a dot that means "any character," so the raw string is not a safe pattern.
Escaping solves this by placing a backslash before each metacharacter, which tells the engine to treat the next character as a plain literal. The set of characters that need escaping is well defined: . * + ? ^ $ ( ) [ ] { } | \ and, depending on how the pattern is delimited, the forward slash. Escaping every one of these — and only these — produces a pattern that matches the original text exactly, no more and no less. Doing it by hand is error-prone because it is easy to miss one character or to over-escape letters and digits, which at best is noise and at worst changes the meaning (in many engines \b is a word boundary, not a literal "b").
This is exactly what a language's built-in helper does — JavaScript developers often reach for a one-line replace with the metacharacter class, Python has re.escape, and most languages offer an equivalent. The most common real-world need is building a pattern dynamically from user input or a variable: if you interpolate an untrusted or arbitrary string straight into a regex, you risk both incorrect matches and, in some cases, a denial-of-service from a pathological pattern. Escaping the dynamic portion first makes it a safe literal. The reverse operation, unescaping, is handy when you are handed a generated pattern and want to read the plain text it was built from, or when you need to move a literal between a regex context and a non-regex one. Note that escaping makes a string safe as a literal; it does not validate or sanitize a pattern you intend to keep as a working regex.
Common use cases
- Dynamic patterns. Safely insert a variable or user input into a regex as a literal match.
- Find & replace. Search for text containing dots, parentheses, or symbols without them acting as operators.
- Building from strings. Escape a filename, URL, or price so it matches exactly in code.
- Reading patterns. Unescape a generated regex to see the plain text behind it.