source: trip-planner-front/node_modules/core-js/modules/es.string.match.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1'use strict';
2var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
3var anObject = require('../internals/an-object');
4var toLength = require('../internals/to-length');
5var toString = require('../internals/to-string');
6var requireObjectCoercible = require('../internals/require-object-coercible');
7var advanceStringIndex = require('../internals/advance-string-index');
8var regExpExec = require('../internals/regexp-exec-abstract');
9
10// @@match logic
11fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
12 return [
13 // `String.prototype.match` method
14 // https://tc39.es/ecma262/#sec-string.prototype.match
15 function match(regexp) {
16 var O = requireObjectCoercible(this);
17 var matcher = regexp == undefined ? undefined : regexp[MATCH];
18 return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](toString(O));
19 },
20 // `RegExp.prototype[@@match]` method
21 // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
22 function (string) {
23 var rx = anObject(this);
24 var S = toString(string);
25 var res = maybeCallNative(nativeMatch, rx, S);
26
27 if (res.done) return res.value;
28
29 if (!rx.global) return regExpExec(rx, S);
30
31 var fullUnicode = rx.unicode;
32 rx.lastIndex = 0;
33 var A = [];
34 var n = 0;
35 var result;
36 while ((result = regExpExec(rx, S)) !== null) {
37 var matchStr = toString(result[0]);
38 A[n] = matchStr;
39 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
40 n++;
41 }
42 return n === 0 ? null : A;
43 }
44 ];
45});
Note: See TracBrowser for help on using the repository browser.