Sha256: 29286712d14217149a2da50441a650d6a234a175d287e6e91db97a124ab3e1bf
Contents?: true
Size: 1.61 KB
Versions: 15
Compression:
Stored size: 1.61 KB
Contents
'use strict'; var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic'); var anObject = require('../internals/an-object'); var toLength = require('../internals/to-length'); var requireObjectCoercible = require('../internals/require-object-coercible'); var advanceStringIndex = require('../internals/advance-string-index'); var regExpExec = require('../internals/regexp-exec-abstract'); // @@match logic fixRegExpWellKnownSymbolLogic('match', 1, function (MATCH, nativeMatch, maybeCallNative) { return [ // `String.prototype.match` method // https://tc39.github.io/ecma262/#sec-string.prototype.match function match(regexp) { var O = requireObjectCoercible(this); var matcher = regexp == undefined ? undefined : regexp[MATCH]; return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O)); }, // `RegExp.prototype[@@match]` method // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match function (regexp) { var res = maybeCallNative(nativeMatch, regexp, this); if (res.done) return res.value; var rx = anObject(regexp); var S = String(this); if (!rx.global) return regExpExec(rx, S); var fullUnicode = rx.unicode; rx.lastIndex = 0; var A = []; var n = 0; var result; while ((result = regExpExec(rx, S)) !== null) { var matchStr = String(result[0]); A[n] = matchStr; if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); n++; } return n === 0 ? null : A; } ]; });
Version data entries
15 entries across 15 versions & 6 rubygems