1 | var _curry3 =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_curry3");
|
4 | /**
|
5 | * Replace a substring or regex match in a string with a replacement.
|
6 | *
|
7 | * The first two parameters correspond to the parameters of the
|
8 | * `String.prototype.replace()` function, so the second parameter can also be a
|
9 | * function.
|
10 | *
|
11 | * @func
|
12 | * @memberOf R
|
13 | * @since v0.7.0
|
14 | * @category String
|
15 | * @sig RegExp|String -> String -> String -> String
|
16 | * @param {RegExp|String} pattern A regular expression or a substring to match.
|
17 | * @param {String} replacement The string to replace the matches with.
|
18 | * @param {String} str The String to do the search and replacement in.
|
19 | * @return {String} The result.
|
20 | * @example
|
21 | *
|
22 | * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
|
23 | * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'
|
24 | *
|
25 | * // Use the "g" (global) flag to replace all occurrences:
|
26 | * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
|
27 | */
|
28 |
|
29 |
|
30 | var replace =
|
31 | /*#__PURE__*/
|
32 | _curry3(function replace(regex, replacement, str) {
|
33 | return str.replace(regex, replacement);
|
34 | });
|
35 |
|
36 | module.exports = replace; |
\ | No newline at end of file |