How to use this tool
- Enter literal text.
- Select Update result to view the result.
- Check the method and assumptions below before using the result.
The method, explained
Prefix regular-expression metacharacters with a backslash. Also escape / for slash-delimited JavaScript patterns, and represent line breaks as escaped characters.
Using literal text = Price (USD): $19.99 [sale], the result is Price \(USD\): \$19\.99 \[sale\]. Change these example inputs to match your task; use the method above to check each step.
Understanding your result
No. Replacement strings have different special sequences, such as $&. This output is for matching literal text in the pattern position.
What to keep in mind
This escapes a standalone pattern, not a character-class fragment or a replacement string. It does not execute a regular expression.
Common questions
Does it escape a replacement string too?
No. Replacement strings have different special sequences, such as $&. This output is for matching literal text in the pattern position.
Can I paste it directly inside a JavaScript string?
A source-code string may need another layer of backslash escaping. The output represents the regex pattern itself, not a quoted JavaScript string.
Methodology maintained by ClarityKit. How these tools are built and checked.