Regex Escape
Escape regular expression special characters (. * + ? ^ $ ( ) [ ] { } | \) so text matches literally. Works for JavaScript, Python, Java, PHP and more.
Runs in your browser. Nothing is uploaded.
About Regex Escape
Characters such as ., *, ? and ( have special meaning in a regular expression. To search for the text $19.99 literally, each one needs a backslash: \$19\.99. Regex Escape adds those backslashes for you.
The output works in JavaScript, Python, Java, PHP, Go and .NET. Tick the slash option when you're writing a /pattern/ literal in JavaScript or PHP.
How to use Regex Escape
- Type or paste your text into the input box. Press Sample to see an example.
- Adjust the options. The result updates as you type.
- Copy the result, or press Use as input to chain another transformation.
Frequently asked questions
Is there a built-in function for this?
Python has re.escape, PHP preg_quote and .NET Regex.Escape. JavaScript only recently added RegExp.escape, so many codebases still do it by hand.
Why isn't - escaped?
A hyphen is only special inside a character class. Outside brackets it matches itself.
Is Regex Escape free and private?
Yes. Regex Escape is completely free with no sign-up. Everything runs in your browser, so whatever you type or paste never leaves your device.