Regex Escape
Put backslashes in front of special characters so text can be used as an exact match inside a regex.
How it works
Special characters in a regex such as . * + ? ( ) [ ] { } | ^ $ and \ have a meaning of their own. To match them literally, put a backslash in front. Paste your text and the tool does it, so you can use it as an exact match inside a regex.
Worked example
"price (USD) [10.50]?" becomes "price \(USD\) \[10\.50\]\?".
Good to know
- Tick the option to also escape - and / when the text goes inside a character class or a /regex/ literal.
- Many languages have a built in function: re.escape in Python, Pattern.quote in Java.
- JavaScript does not have a built in RegExp.escape in every browser, so a helper like this is handy.
Common questions
- Which characters are escaped?
- . * + ? ^ $ { } ( ) | [ ] \ and optionally - and /.
- Do I escape spaces?
- No, spaces are literal in a regex unless the x flag is used.
- Why escape at all?
- So a user typed string cannot change the meaning of your pattern.
More in Developer.
ASCII Converter
See the ASCII code of every character in decimal, hex, binary and octal, or turn codes back into text.
OPEN →Axios Request GeneratorFill in a method, URL, headers and body and get a ready Axios Request snippet to copy.
OPEN →Base32 Encoder and DecoderEncode text to Base32 (RFC 4648) or decode it, as used in 2FA secrets.
OPEN →