source: node_modules/ramda/es/match.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: 972 bytes
Line 
1import _curry2 from "./internal/_curry2.js";
2/**
3 * Tests a regular expression against a String. Note that this function will
4 * return an empty array when there are no matches. This differs from
5 * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
6 * which returns `null` when there are no matches.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.1.0
11 * @category String
12 * @sig RegExp -> String -> [String | Undefined]
13 * @param {RegExp} rx A regular expression.
14 * @param {String} str The string to match against
15 * @return {Array} The list of matches or empty array.
16 * @see R.test
17 * @example
18 *
19 * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na']
20 * R.match(/a/, 'b'); //=> []
21 * R.match(/a/, null); //=> TypeError: null does not have a method named "match"
22 */
23
24var match =
25/*#__PURE__*/
26_curry2(function match(rx, str) {
27 return str.match(rx) || [];
28});
29
30export default match;
Note: See TracBrowser for help on using the repository browser.