Invokes `fn` for each "capture group" encountered in the PCRE `pattern`,
and inserts the returned value into the pattern instead of the capture
group itself.

@private
553336
function replaceCaptureGroups (pattern, fn) {
  var start;
  var depth = 0;
  var escaped = false;

  for (var i = 0; i < pattern.length; i++) {
    var cur = pattern[i];
    if (escaped) {
      // skip this letter, it's been escaped
      escaped = false;
      continue;
    }
    switch (cur) {
      case '(':
        // we're only interested in groups when the depth reaches 0
        if (0 === depth) {
          start = i;
        }
        depth++;
        break;
      case ')':
        if (depth > 0) {
          depth--;

          // we're only interested in groups when the depth reaches 0
          if (0 === depth) {
            var end = i + 1;
            var l = start === 0 ? '' : pattern.substring(0, start);
            var r = pattern.substring(end);
            var v = String(fn(pattern.substring(start, end)));
            pattern = l + v + r;
            i = start;
          }
        }
        break;
      case '\\':
        escaped = true;
        break;
    }
  }
  return pattern;
}
853016
function(fn, context, onDestroy){
      /** @cut */ var cursor = this;
      /** @cut */ while (cursor = cursor.handler)
      /** @cut */   if (cursor.fn === fn && cursor.context === context)
      /** @cut */     consoleMethods.warn('basis.Token#attach: duplicate fn & context pair');

      this.handler = {
        fn: fn,
        context: context,
        destroy: onDestroy || null,
        handler: this.handler
      };
    }
598125
def capture(self, pattern, name=None):
        

        if isinstance(pattern, basestring):
            pattern = re.compile(pattern)

        def munge(self, value):
            match = pattern.match(value)
            if not match:
                return NONE
            for group in [name or self.name, 1]:
                try:
                    return match.group(group)
                except IndexError:
                    pass
            return NONE

        return self.munge.attach(self)(munge)
536948
function $$core$$createRegExpRestore () {
        var esc = /[.?*+^$[\]\\(){}|-]/g,
            lm  = RegExp.lastMatch || '',
            ml  = RegExp.multiline ? 'm' : '',
            ret = { input: RegExp.input },
            reg = new $$core$$List(),
            has = false,
            cap = {};

        // Create a snapshot of all the 'captured' properties
        for (var i = 1; i <= 9; i++)
            has = (cap['$'+i] = RegExp['$'+i]) || has;

        // Now we've snapshotted some properties, escape the lastMatch string
        lm = lm.replace(esc, '\\$&');

        // If any of the captured strings were non-empty, iterate over them all
        if (has) {
            for (var i = 1; i <= 9; i++) {
                var m = cap['$'+i];

                // If it's empty, add an empty capturing group
                if (!m)
                    lm = '()' + lm;

                // Else find the string in lm and escape & wrap it to capture it
                else {
                    m = m.replace(esc, '\\$&');
                    lm = lm.replace(m, '(' + m + ')');
                }

                // Push it to the reg and chop lm to make sure further groups come after
                $$core$$arrPush.call(reg, lm.slice(0, lm.indexOf('(') + 1));
                lm = lm.slice(lm.indexOf('(') + 1);
            }
        }

        // Create the regular expression that will reconstruct the RegExp properties
        ret.exp = new RegExp($$core$$arrJoin.call(reg, '') + lm, ml);

        return ret;
    }
1008776
function(node, pattern) {
		if (!!node && (node.nodeType === 3) && pattern.exec(node.nodeValue)) {
			node.nodeValue = node.nodeValue.replace(pattern, '');
		}
	}
125460
function wrapGLCall(fn, callback) {
    const glFn = gl[fn]
    gl[fn] = function() {
      callback(arguments)
      return glFn.apply(this, arguments)
    }
  }
1104608
function addHooks(fn, value) {
  // Upcast val to an array
  var values = value;
  if (!Array.isArray(values)) {
    values = [value];
  }

  // Call each of the functions with hook
  values.forEach(fn);
}
924772
function(regex) {
  var self = this; var re = new RegExp(regex);
  var keys = {};
  self.init = function() { keys = {}; };
  self.accumulate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v+1; else keys[k] = 1; // count by key
  };
  self.compensate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v-1; else keys[k] = 1;
  };
  self.emit = function() {
    return keys;
  };
  self.make = function() { return new WideFinderFunction(regex); };
}
1147870
function tryCatch1 (fn, arg1) {
  var errorObject = {};
  try {
    errorObject.value = fn(arg1);
  }
  catch (e) {
    errorObject.error = e;
  }
  return errorObject;
}
512885
function forEachItemGroup (callback) {
        this.items.each(function (item) {
            if (ItemGroup.isItemGroup(item)) {
                item.forEachItemGroup(callback);
                callback(item, this); // eslint-disable-line callback-return
            }
        }, this);
    }
13422
function _callFn(callQueue, target){
        var result = null;
        
        callQueue = callQueue.reverse();
        baidu.each(callQueue, function(item){
            result = target.call(item.fnName, item.params);
            item.callBack(result);
        });
    }
241677
function serialEach(object, fn, callback) {
  var keys = Object.keys(object);
  next();
  function next(err) {
    if (err) return callback(err);
    var key = keys.shift();
    if (!key) return callback();
    fn(key, object[key], next);
  }
}
667268
function _matchRegExp(val) {
  const expression = `${_escapeRegExp(val)}($|\\s|\\>|\\+|~|\\:|\\[)`;
  let expressionPrefix = '(^|\\s|\\>|\\+|~)';
  if (_isPlaceholder(val)) {
    // We just want to match an empty group here to preserve the arguments we
    // may be expecting in a RegExp match.
    expressionPrefix = '()';
  }
  return new RegExp(expressionPrefix + expression, 'g');
}
1320810
function wrap(fn, args, key) {
    const self = this;

    if (key === undefined && typeof(args) === 'string') {
      key = args;
      args = [];
    }
    if (!args) args = [];

    return function wrapper(context, cb) {
      const copyArgs = args.slice(args);
      copyArgs.unshift(self);
      copyArgs.push(onWrappedDone);
      return fn.bind.apply(fn, copyArgs)();

      function onWrappedDone(err, result) {
        if (err) return cb(err);

        if (key) context[key] = result;
        return cb(null);
      }
    };
  }
60108
function workFn() {
      var spec = getCurrentSpec();
      var modules = spec.$modules || [];
      modules.unshift('ngMock');
      modules.unshift('ng');
      var injector = spec.$injector;
      if (!injector) {
        injector = spec.$injector = angular.injector(modules);
      }
      for(var i = 0, ii = blockFns.length; i < ii; i++) {
        try {
          injector.invoke(blockFns[i] || angular.noop, this);
        } catch (e) {
          if(e.stack) e.stack +=  '\n' + stack;
          throw e;
        }
      }
    }
1007808
function _fnNameArray (context, object, target, filterContext) {
    var collected = '',
        length = target.length,
        ref, i;
    for (i = 0; i < length; i++) {
      object._value = target[i];
      if (!object._value) {
        continue;
      }
      object._index = i;
      collected += context.include(_src, object);
    }
    return collected;
  }
564090
function forEachValue (obj, fn) {
  Object.keys(obj).forEach(function (key) { return fn(obj[key], key); });
}