quoteRegExp()

Turn any string into a regular expression that matches the exact string without worrying about encoding the metacharacters yourself.

This function is valid in v2.0.0 to v2.13.1. This function has been downloaded 28 times.

Parameters

{string} str
The string that should be modified so that any characters that would normally serve as metacharacters in a regular expression will be escaped.
{boolean|string=} flagsOrMakeRegExp Optional, Default:false
If not specified or if false, it will cause just the escaped version of str to be returned. If true, it will be as if the empty string was passed in. A string represents the flags to be set in the returned regular expression.

Returns

{RegExp|string}
If flagsOrMakeRegExp is true a regular expression without flags will be returned. If flagsOrMakeRegExp is a non-empty string, a regular expression with the specified characters representing the corresponding flags will be returned. In all other cases just the escaped string that can be used as a regular expression will be returned.