Version 1
[yaffs-website] / node_modules / grunt-legacy-log / node_modules / lodash / string / escapeRegExp.js
diff --git a/node_modules/grunt-legacy-log/node_modules/lodash/string/escapeRegExp.js b/node_modules/grunt-legacy-log/node_modules/lodash/string/escapeRegExp.js
new file mode 100644 (file)
index 0000000..176137a
--- /dev/null
@@ -0,0 +1,32 @@
+var baseToString = require('../internal/baseToString'),
+    escapeRegExpChar = require('../internal/escapeRegExpChar');
+
+/**
+ * Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns)
+ * and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern).
+ */
+var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,
+    reHasRegExpChars = RegExp(reRegExpChars.source);
+
+/**
+ * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?",
+ * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`.
+ *
+ * @static
+ * @memberOf _
+ * @category String
+ * @param {string} [string=''] The string to escape.
+ * @returns {string} Returns the escaped string.
+ * @example
+ *
+ * _.escapeRegExp('[lodash](https://lodash.com/)');
+ * // => '\[lodash\]\(https:\/\/lodash\.com\/\)'
+ */
+function escapeRegExp(string) {
+  string = baseToString(string);
+  return (string && reHasRegExpChars.test(string))
+    ? string.replace(reRegExpChars, escapeRegExpChar)
+    : (string || '(?:)');
+}
+
+module.exports = escapeRegExp;