JavaScript
StringescapeRegExp Method
Syntax
String.escapeRegExp()
Returns
- valuestring
The value of the string with regular expression characters escaped.
Description
Extension to the native string variable to convert a string into a regular expression safe string.
Example
var str = '[MA]'; str = str.escapeRegExp(); // str = '\[MA\]' var re = new RegExp(str,'gi');