source: node_modules/ramda-adjunct/lib/escapeRegExp.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1011 bytes
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _isString = _interopRequireDefault(require("./isString"));
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8/**
9 * Escapes the RegExp special characters.
10 *
11 * @func escapeRegExp
12 * @memberOf RA
13 * @since {@link https://char0n.github.io/ramda-adjunct/2.21.0|v2.21.0}
14 * @category String
15 * @sig String -> String
16 * @param {string} val the value to escape
17 * @return {string}
18 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping|MDN Regular Expressions Escaping}
19 * @example
20 *
21 * RA.escapeRegExp('[ramda-adjunct](https://github.com/char0n/ramda-adjunct)'); //=> '\[ramda\-adjunct\]\(https://github\.com/char0n/ramda\-adjunct\)'
22 */
23var escapeRegExp = (0, _ramda.when)(_isString["default"], (0, _ramda.replace)(/[.*+?^${}()|[\]\\-]/g, '\\$&'));
24var _default = escapeRegExp;
25exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.