About Regex Escape

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 : Go to Regex Escape to use the tool.
  2. Review the controls : Check the available fields and actions before you start.
  3. Use the result : Run the action you need, then copy or share the output.

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.

Fields

  • Method

Actions

  • Escape text