Skip to content
OddsockLocal
Local
Source text

Formatting

4 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste the text that should match literally.
  2. Copy the escaped pattern.
  3. Use it as the pattern in the regex tester if you want to see matches.
  4. Do not escape a pattern you already wrote on purpose. Escaping twice adds extra backslashes.

What is Regex escape?

Regex escape is for the moment a price, a file name or a user string has to match exactly and the regex engine would otherwise treat the punctuation as syntax. price is $12.50 (USD) becomes price is \$12\.50 \(USD\). The dollar, the dot and the parentheses are escaped. Letters and spaces are not.

Read more

The escaped characters are the usual metacharacters: . * + ? ^ $ { } ( ) | [ ] \ and the rest of that set. The page does not compile a pattern and does not look at a second text. There is no flag control. If you want to find the matches, paste the escaped text into the tester as the pattern.

Escaping is not encoding. The result is still the same characters, with backslashes added. It will not turn a space into %20, and it will not hide the string.

Use cases

  • A search box should find the price $12.50, and a raw pattern would treat the dot as any character and the dollar as an end anchor.
  • A filename with brackets has to be a literal inside a larger expression.
  • You are building a pattern from user input and the input must not change the meaning of the expression.
  • You want the escapes written out before you paste them into the tester and turn flags on.

A price that is full of metacharacters

price is $12.50 (USD)

price is \$12\.50 \(USD\)

Why use Oddsock

The dot in 12.50 would match any character. Escaping it is what makes 12x50 fail to match.

Related tools

Using this tool

In a regex, . matches any character. \. matches a period. $12.50 without the escapes would also match $12X50.