src code

class method RegExp.escape

RegExp.escape(str) → String
  • str (String) – A string intended to be used in a RegExp constructor.

Escapes any characters in the string that have special meaning in a regular expression.

Use before passing a string into the RegExp constructor.