Regex Escape Online
Turn any text into a regular expression pattern that matches it literally. Every special character is escaped, and you can copy a bare pattern, a /regex/ literal or a new RegExp() string. Nothing is uploaded.
How to use Regex Escape on KickSolve
Three quick steps, no account needed.
Why choose KickSolve
Built for speed, privacy and accurate results.
About Regex Escape on KickSolve
What it does and how to get the best results.
What does regex escape do?
In a regular expression some characters have a special meaning. A dot matches any character and a plus repeats the one before it. To match them as plain text you put a backslash in front. Regex escape adds those backslashes for you, so 5.00 becomes 5\.00.
Characters that need escaping in a regex
The special characters are . * + ? ^ $ { } ( ) | [ ] \ and the forward slash / inside a JavaScript regex literal. A hyphen only needs escaping inside a character class such as [a\-z], so it is a separate option here. New lines and tabs are written as \n and \t.
How to escape a string for a regular expression
Paste the text in the top box. The escaped pattern appears below. Use Pattern when you build a regex in code, /regex/ for a JavaScript literal with flags, or RegExp() for a string you can paste into new RegExp(...). The backslashes are doubled in that form, as a string needs.
Works in other languages too
The escapes use plain backslashes before punctuation, which JavaScript, Python, PHP, Java and most other engines accept. Python has re.escape, PHP has preg_quote and Java has Pattern.quote for the same job. Newer JavaScript engines also include RegExp.escape(), but this page works in any browser.
Unescape a regex
To remove the backslashes again, use regex unescape.
Regex Escape examples
Real input and output so you can see exactly what changes.
Price with brackets
Input
price (USD) = $5.00 [approx.]Output
price \(USD\) = \$5\.00 \[approx\.\]Operators
Input
a+b*c?Output
a\+b\*c\?URL with slashes
Input
https://example.com/path?x=1Output
https:\/\/example\.com\/path\?x=1When do you need to escape a regex?
Common reasons people use this page.
Privacy, limits and browser support
What happens to your data and what to expect.
- How it works: with KickSolve, the conversion runs in your browser with JavaScript. Your text is not sent to a server and is not stored.
- Limits: there is no limit set by us. Very large text, many megabytes, depends on your device memory.
- Browsers: current Chrome, Edge, Firefox and Safari on desktop and mobile.
Read the KickSolve privacy policy for details about the site itself.
Frequently asked questions
Quick answers.
How do I escape a string for a regular expression?
Paste the text into the top box. Every special character gets a backslash, so the pattern matches your text literally.
Which characters are special in regex?
The dot, star, plus, question mark, caret, dollar, braces, parentheses, pipe, square brackets and backslash. A hyphen is special only inside a character class.
Why is the forward slash escaped?
Inside a JavaScript regex literal, an unescaped slash ends the pattern. Escaping it is harmless in other places.
What does Escape hyphen do?
It writes - as \-. Turn it on if you will put the text inside square brackets. Leave it off otherwise.
What is the RegExp() output?
It is a ready-to-paste new RegExp("pattern", "flags") call with backslashes doubled for the string.
Does this work in Python, PHP or Java?
Yes for the pattern text. Those languages also have their own helper such as re.escape or preg_quote.
Is my text uploaded anywhere?
No. Everything runs in your browser.
Is it free?
Yes. It is free and needs no signup.
More free tools from KickSolve
Related string and developer tools.