es6.regexp.search.js 394 B

12345678910
  1. // @@search logic
  2. require('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search) {
  3. // 21.1.3.15 String.prototype.search(regexp)
  4. return [function search(regexp) {
  5. 'use strict';
  6. var O = defined(this);
  7. var fn = regexp == undefined ? undefined : regexp[SEARCH];
  8. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  9. }, $search];
  10. });