Toolstia / Regex escape tool
regex escape tool
Paste text and get a version that a regular expression will match literally. Choose the language so the escaping follows its own rules.
Use the result inside a regular expression to match your text exactly. Special characters such as . * + ? ( ) [ ] and $ lose their special meaning.
How it works
- Paste the text to match.
- Choose the regex flavor.
- Copy the escaped pattern.
Why escape?
Characters such as . * + ? ( ) [ ] { } | ^ and $ have special meanings in a regex. Escaping with a backslash makes them plain characters.
Language rules
JavaScript also escapes the forward slash. Python escapes spaces and dashes like re.escape. PHP follows preg_quote and Go follows QuoteMeta. Java wraps the text in \Q and \E.
User input
Always escape text typed by users before putting it inside a pattern, so it cannot change what the pattern means.
Testing
Try the result in the regex tester to confirm it matches your original text.
Questions
Does it escape the delimiters?
Only where the language needs it. Add your own delimiters, such as / in PHP, around the pattern.
Can it unescape?
No, this tool only escapes.
Is my text stored?
Everything happens in your browser, and nothing you enter is sent anywhere.