Escape text for a regular expression
Regular expressions use characters such as periods, brackets, parentheses, and question marks as syntax. When you need to search for those characters exactly, they must be escaped so the regex engine treats them as ordinary text.
Paste a literal string into this tool to generate an escaped pattern immediately. For example, [array_name]($var) becomes \[array_name\]\(\$var\), which matches that exact text instead of a character class or capture group.
When literal matching is useful
Literal patterns are helpful when searching source code, log entries, user input, file paths, or generated identifiers. Escaping the input avoids accidental wildcard matching and makes the pattern safe to combine with other regex components.
The converter handles the standard regex metacharacters: backslashes, carets, dollar signs, periods, asterisks, plus signs, question marks, parentheses, square brackets, braces, and pipes. Characters without a special regex meaning are kept unchanged.
Use the output in your language
The result is a regex pattern, not a language-specific string literal. When placing it in JavaScript, PHP, Python, or another language, you may need to escape backslashes once more according to that language's string syntax.