Escape Regex
Add backslashes before characters that are special in regular expressions, so a piece of plain text can be matched literally. Useful when inserting user input into a regex or search script.
How to use
- Special characters such as brackets, dots, and asterisks are escaped, while ordinary text stays unchanged.
- The escaped result is meant for use inside a regex literal, not for display as normal text.
FAQ
Does every character get a backslash?
Only characters with special meaning in a regex need escaping, so ordinary letters and digits usually stay as they are. This keeps the result shorter and easier to read; check the output for the exact set.
Can the escaped text be shown to readers?
The backslashes appear as literal characters and look odd in normal copy. They belong inside code or a regular expression, so unescape or rewrite the text before showing it to readers.