Package Exports
- escape-regex-string
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (escape-regex-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
escape-regex-string 
Escapes a string literal for use as an argument in the standard RegExp constructor.
Interface
escape-regex-string
(require('escape-regex-string'))(patternString[, escapeCharsRegex])
- patternString String
- escapeCharsRegex RegExp
- Defaults to value of member escape-regex-string.defaultEscapeCharsRegex (see below)
Returns the passed patternString with all RegExp tokens escaped.
escape-regex-string.defaultEscapeCharsRegex
(require('escape-regex-string')).defaultEscapeCharsRegex
A read-only RegExp instance containing the default pattern used to escape passed strings. If a RegExp instance is manually passed into a function call to this module, the passed RegExp value will be used instead of this default value.
Example Usage
var escapeRegexString = require('escape-regex-string');
var regexString = '$&*()awsd';
var escapedRegexString = escapeRegexString(regexString); // '\\$&\\*\\(\\)awsd'
var regExpObject = new RegExp(escapedRegexString);
console.log(regExpObject); // /\$&\*\(\)awsd/
Feedback
I wrote this miniature module to practice with a few of the tools, libraries, and workflows available to JS developers. I welcome constructive criticism and advice.