Regex Escape Tool

Escape special regex characters so your text is treated as a literal in regular expressions.

  1. Home
  2. Utility
  3. Regex Escape Tool

Escaped chars: 0

Enter text above to see the escaped output.

Special Regex Characters

Character Name Escaped
.Dot / Wildcard\\.
^Caret / Start anchor\\^
$Dollar / End anchor\\$
*Asterisk / Quantifier (0+)\\*
+Plus / Quantifier (1+)\\+
?Question / Quantifier (0-1)\\?
( )Parentheses / Group\\( \\)
[ ]Brackets / Character class\\[ \\]
{ }Braces / Quantifier range\\{ \\}
\\Backslash / Escape\\\\
|Pipe / Alternation\\|

What Is Regex Escaping?

Regex escaping is the process of prefixing special regular expression characters with a backslash (\\) so they are treated as literal characters rather than as regex operators. In regular expressions, characters like ., *, +, ?, (, ), [, ], {, }, ^, $, |, and \\ itself have special meanings. When you want to match these characters literally (e.g., matching a literal dot in a filename), you must escape them.

For example, the regex pattern \d+\.\d+ matches numbers like 3.14. The dot is escaped with a backslash so it matches a literal period instead of the "any character" wildcard. Without escaping, 3.14 would also match 3a14, 3-14, or any other character in the dot position.

This tool is essential for developers working with regular expressions in programming languages, text editors, database queries, or log analysis. It helps you quickly escape user-supplied input before using it in a regex pattern, preventing both unintended matches and potential ReDoS (Regular Expression Denial of Service) vulnerabilities from unescaped input.

How to Use This Regex Escape Tool

  1. Enter text — Type or paste the string containing special regex characters into the input textarea. Use the Load Sample button to see an example.
  2. Select characters to escape — Use the checkboxes to choose which special characters to escape. By default, all major regex metacharacters are selected. You can disable specific characters if your use case requires leaving some unescaped.
  3. View escaped output — The escaped result appears in the output section, with a count of how many characters were escaped.
  4. Copy the result — Click Copy Escaped to copy the escaped string to your clipboard for use in your regex pattern.

Frequently Asked Questions

Which characters need to be escaped in a regex?

The 12 special regex metacharacters that typically need escaping are: ., ^, $, *, +, ?, (, ), [, ], {, }, \\, and |. The hyphen - also needs escaping inside character classes.

Do different programming languages use different escape rules?

The basic metacharacters are standard across most regex flavors (PCRE, JavaScript, Python, Java, .NET, Ruby, Go). However, some languages like JavaScript require double-escaping when writing regex patterns in string literals (e.g., "\\." instead of "\.").

What is the difference between a regex escape and a string escape?

A string escape (like \\n for newline) is processed by the programming language's string parser before the regex engine sees the pattern. A regex escape (like \\. for a literal dot) is processed by the regex engine. When using regex in code, both levels of escaping may apply.

Should I escape user input in regex patterns?

Yes, absolutely. When incorporating user-supplied text into a regex pattern, always escape special characters first. This prevents both logic errors (unintended matches) and security vulnerabilities like ReDoS attacks where crafted input can cause catastrophic backtracking.

Does this tool support different regex flavors?

The tool escapes all standard POSIX and PCRE metacharacters, which covers the vast majority of regex engines. The output is safe for use in JavaScript, Python, Java, .NET, PHP (PCRE), Ruby, and most other modern regex implementations.

Last updated: 9 Jul 2026