Category: Developer tools
Regex Escape Tool
Escape text for literal use inside a regular expression
Escape every regex metacharacter so your text matches literally, then copy it as a /pattern/flags literal or a new RegExp(...) call. Runs entirely in your browser.
Prices start at \$4\.99 \(per item\)\? \[ask sales\]
/Prices start at \$4\.99 \(per item\)\? \[ask sales\]/g
new RegExp("Prices start at \\$4\\.99 \\(per item\\)\\? \\[ask sales\\]", "g")Everything on this page is processed in your browser. Nothing is uploaded.
What this tool does
Building a pattern that matches a literal string such as a price, a file path or a URL fails as soon as the text contains a character regex treats specially, like a dot, a parenthesis or a question mark. This tool escapes every metacharacter the JavaScript regex engine recognises and renders the result two ways: as a `/pattern/flags` literal and as a `new RegExp(...)` call, so either fits straight into your code.
How to use it
- Paste the literal text you want to match — a price, a file path, a URL — and every metacharacter the JavaScript regex engine recognises is escaped for you.
- Set the flags you want on the generated pattern, such as g for a global match or i for a case-insensitive one, and the output updates with them.
- Copy whichever form your code needs: the escaped text on its own, the `/pattern/flags` literal, or the `new RegExp(...)` constructor call.
Privacy
This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.
Frequently asked questions
- How do I use Regex Escape Tool?
- Paste the literal text you want to match, set the flags you want on the generated pattern such as g or i, then copy the escaped text, the literal form or the constructor call. All three steps happen on this page.
- Which inputs and options does Regex Escape Tool support?
- The input is one block of literal text you want matched exactly, and the option is the set of regex flags applied to the generated pattern, such as g or i. Formats, algorithms and batch features that are not shown on the page are not supported.
- How do I view or copy the result?
- The escaped result is rendered two ways — as a `/pattern/flags` literal and as a `new RegExp(...)` call — and you can copy the escaped text, the literal form or the constructor call, whichever fits your code.
- Is my input, file, or result uploaded?
- No. Inputs, files, settings, and results stay in the browser and are not uploaded to LocalTools. The escaping is done by JavaScript running on the page, so what you paste never leaves your device.
- What does this tool not support?
- It only escapes the metacharacters the JavaScript regex engine recognises. It does not test a pattern against sample text, unescape an existing pattern, target other regex dialects, or handle files and batches, and there are no accounts, sync or cloud history.