Fork me on GitHub

Module core/regexp

Class RegExp

Static Methods


RegExp.escape (str)

Accepts a string; returns the string with regex metacharacters escaped. the returned string can safely be used within a regex to match a literal string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., , ^, $, |, #, [comma], and whitespace.

Parameters

String str the string to escape

Returns

String the escaped string