Text & writing ● Local processing

Regular Expression Escaper

Escape regular-expression metacharacters in literal text.

Preparing tool…
Try a small example

Try a small example

Load the fictional example in a cleared form. Check the options, run the tool if needed, and compare the result below.

Escape literal text as a JavaScript regex pattern, with separate output modes for RegExp constructor patterns and slash-delimited regex literals. Paste literal text, choose whether you will pass the result to new RegExp() or place it between /slashes/, then run the escaper. The output is only the regex pattern; slash-delimited mode escapes / and converts LF, CR, U+2028 and U+2029 line terminators to regex escapes. Output is the pattern only: it is not a quoted JavaScript string, a complete /pattern/ expression, or an escaped replacement string. In slash-delimited mode, JavaScript line terminators, including Unicode line and paragraph separators, are emitted as escapes.

Literal text to escape

price (EUR) = 12.50?

Expected output

price \(EUR\) = 12\.50\?

The example is unavailable until the tool is ready.

Text is processed in your browser.

✓ Local processing✓ No account✓ Inputs processed here✓ Free

Quick answer

Escape literal text as a JavaScript regex pattern, with separate output modes for RegExp constructor patterns and slash-delimited regex literals.

The page and its assets load from the site; this operation uses your entered values only in this browser and does not send them to a calculation endpoint.

How to use it

Paste literal text, choose whether you will pass the result to new RegExp() or place it between /slashes/, then run the escaper. The output is only the regex pattern; slash-delimited mode escapes / and converts LF, CR, U+2028 and U+2029 line terminators to regex escapes.

Limits

Output is the pattern only: it is not a quoted JavaScript string, a complete /pattern/ expression, or an escaped replacement string. In slash-delimited mode, JavaScript line terminators, including Unicode line and paragraph separators, are emitted as escapes.

Frequently asked questions

Which output mode should I choose?

Choose RegExp constructor when passing the result to new RegExp(pattern). Choose slash-delimited literal when placing it between /slashes/ in JavaScript source.

Does the result include JavaScript string quotes or regex delimiters?

No. It returns the escaped pattern only. In slash-delimited mode it escapes / and converts line breaks to \n or \r.

Sources and references

These references document the cited standard or browser API; they do not validate the tool’s output.