Escape literal text so it matches itself, then wrap it in a string literal for JavaScript, Python, Java, C#, Go or PHP.
Waiting for text
Paste literal text and get a pattern that matches exactly that text and nothing else.
Paste your text
The escaped pattern appears here, ready to paste into the language you picked above — with that language's own string escaping already applied.
The pattern itself, as you would write it between slashes.
Regex Escape Helper runs entirely on your device — the text is escaped as a string and nothing is compiled or run.
You’re on the Free plan. Compare plans
Escaping literal text is the easy half. The half that goes wrong is the second layer: a pattern is almost never used on its own, it is pasted into a string literal, and that language's own escaping then applies on top. `\\.` in a pattern is `"\\\\."` in Java or C# source and `r"\\."` in Python — and getting that wrong is the commonest reason an escaped pattern still fails.
So the pattern and its per-language literal are produced together. Pick the language and you get something you can paste directly, with the raw-string or verbatim form used where the language has one, because that is what avoids the doubling rather than merely surviving it.
The escaped set is the one `RegExp.escape` standardises, plus `-`. A hyphen is only special inside a character class, and escaping it outside one is harmless — which means the output is safe to drop into a class as well as outside one.
This is the right fix for building a pattern from user input or from a filename. Interpolating unescaped text into a pattern is how a dot comes to match any character and how a stray `(` becomes a syntax error at runtime.
Because `-` is special inside a character class, and escaping it outside one changes nothing. Doing it always means the output is safe to paste into a class as well as outside one.
The set `RegExp.escape` standardises — `. * + ? ^ $ { } ( ) | [ ] \\ /` — plus the hyphen. Everything else already matches itself.
Because Java has no raw strings, so every backslash in the pattern has to be doubled in the source. This is the single commonest Java regex mistake, which is why the literal form is generated rather than left to you.
That is what it is for. Interpolating unescaped text into a pattern is how a dot ends up matching any character and how a stray bracket becomes a runtime syntax error.