Regular Expressions 101

Community Patterns

Escape Regex Meta Characters (v2)

0

Regular Expression
ECMAScript (JavaScript)

/
([-\[\]{}()*+?.,\\\/^$|#])
/
g

Description

This expression escapes characters, which have a special meaning in regex, like .?[]/ and so on. Use it to transform a string that you want to use literally in another regex. This is the second version, bug in replace string has been fixed.

Submitted by Florian Andresen - 7 years ago