Regex Escape Tool — Escape Special Characters for RegEx

Escape all RegEx metacharacters in a string so it can be used as a literal pattern. Handles dots, stars, brackets, pipes, and all other special regex characters correctly.

Key Features

How to Use

  1. Enter the literal string you want to match into the input field.
  2. Select your target language or dialect if custom delimiters are used.
  3. Click "Escape RegEx" to prefix all metacharacters with backslashes.
  4. Copy the escaped pattern to incorporate into your regular expression.

Example

Sample input

Price: $19.99 (50% off)?

Sample output

Price: \$19\.99 \(50% off\)\?

Edge Cases

Frequently Asked Questions

Why must metacharacters be escaped in regular expressions?

Characters like ".", "*", and "?" have reserved operational meanings in RegEx engines. Escaping them forces the engine to match the literal character instead.

Is this equivalent to preg_quote in PHP or RegExp.escape in JS?

Yes. The escaping logic matches standard functions like PHP’s preg_quote() and the proposed JavaScript RegExp.escape() specification.

Are alphanumeric characters or spaces affected?

No. Letters, numbers, spaces, and punctuation that do not have special RegEx significance remain unescaped.

Related Tools

Privacy notice: when you run this tool, your input is sent over HTTPS to our server, processed in memory and returned. It is not stored or logged. Avoid pasting live secrets such as private keys or passwords.