Regex Escape

Escape text with either RegExp.escape() or a simple one-liner.

Escaped text

Run a tool to see output.

Choose the browser-native method for the safest result, or use the simple one-liner for a shorter result that is easier to read and copy. The native method can hex-escape the first letter or digit so escaped text stays safe when it is joined onto other pattern text.

How to Use

Choose a method, paste text into the input field, and copy the escaped result into your pattern.

  1. Open the tool : Start with Regex Escape, then follow the steps below.
  2. Set the inputs : Adjust the fields to match the values you want to process.
  3. Run and copy : Use the action buttons, then copy or share the result if you need it elsewhere.

Common Questions

What does Regex Escape do?

It turns plain text into a version you can paste safely into a JavaScript regular expression.

What is the difference between Browser and Simple?

Browser uses RegExp.escape() for the safest output. Simple only backslashes the usual regex metacharacters, so the result is shorter and easier to read.

Why does RegExp.escape() treat the first character differently?

RegExp.escape() can hex-escape a leading letter or digit so the escaped text cannot accidentally join with text that already comes before it in a larger pattern.

All Tools