Return the string to be substituted for the match.
548940
def _string_to_substitute(self, mo, methods_dict):
        
        matched_text, f_name = mo.groups()
        # matched_text is the complete match string. e.g. plural_noun(cat)
        # f_name is the function name. e.g. plural_noun

        # Return matched_text if function name is not in methods_dict
        if f_name not in methods_dict:
            return matched_text

        # Parse the matched text
        a_tree = ast.parse(matched_text)

        # get the args and kwargs from ast objects
        args_list = [self._get_value_from_ast(a) for a in a_tree.body[0].value.args]
        kwargs_list = {
            kw.arg: self._get_value_from_ast(kw.value)
            for kw in a_tree.body[0].value.keywords
        }

        # Call the corresponding function
        return methods_dict[f_name](*args_list, **kwargs_list)
979082
def to_match(self):
        """"""
        self.validate()

        mark_name, field_name = self.location.get_location_name()
        validate_safe_string(mark_name)
        validate_safe_string(field_name)

        return u'%s.%s' % (mark_name, field_name)
526615
def _from_match(match):
        """"""
        addr_beg, addr_end, r, w, x, p, offset, dev, inode, pathname = match.groups()
        return MemoryRegion(addr_beg=int(addr_beg, 16),
                            addr_end=int(addr_end, 16),
                            readable=(r == "r"),
                            writable=(w == "w"),
                            executable=(x == "x"),
                            private=(p == "p"),
                            offset=int(offset, 16),
                            dev=dev,
                            inode=int(inode),
                            pathname=pathname)
1090373
def substitution_set(string, indexes):
    
    strlen = len(string)
    return {mutate_string(string, x) for x in indexes if valid_substitution(strlen, x)}
410096
public static String substitute(String input, Map<String,Object> values) {
        StringBuilder output = new StringBuilder(input.length());
        int index = 0;
        Matcher matcher = SUBST_PATTERN.matcher(input);
        while (matcher.find()) {
            String match = matcher.group();
            output.append(input.substring(index, matcher.start()));
            Object value = values.get(match.substring(2, match.length() - 2));
            output.append(value == null ? "" : String.valueOf(value));
            index = matcher.end();
        }
        output.append(input.substring(index));
        return output.toString();
    }
468629
public Expression2 substitute(String value, String replacement) {
    return substitute(Expression2.constant(value), Expression2.constant(replacement));
  }
574647
def match(self, s):
      
      self.matches = self.re.search(s)
      return self.matches
849632
def _pattern_match(self, item, pattern):
        """"""
        if pattern.endswith('*'):
            return item.startswith(pattern[:-1])
        else:
            return item == pattern
1282110
def get_matching(content, match):
    
    if match != "":
        lines = [line for line in content.split("\n") if match in line]
        content = "\n".join(lines)
    return content
1095327
def matches_input(self, optimized_str):
        """"""

        if all([keyword in optimized_str for keyword in self['keywords']]):
            logger.debug('Matched template %s', self['template_name'])
            return True
856093
def sub(self, replace, string, count=0):
      
      return self.re.sub(replace, string, count)
352911
def retag_string(self, string, tags):
        """"""
        for i, tag in enumerate(tags):
            bracketed = '<%s>' % i
            string = re.sub(bracketed, tag, string, 1)
        return string
601189
function replace(regex, source, options) {
  var valueOrFn = getValueOrMatchFn(options.value)
  source.replace(regex, function () { return '' })
  return source.replace(regex, valueOrFn)
}
177776
def _maybe_replace_path(self, match):
        
        path = match.group(0)
        if self._should_replace(path):
            return self._replace_path(path)
        else:
            return path
831862
def match_replace_regex(regex, src_namespace, dest_namespace):
    """"""
    match = regex.match(src_namespace)
    if match:
        return dest_namespace.replace("*", match.group(1))
    return None
1358629
protected String getMatcherString(MatchType matchType, String paramName) {
    String matchB;
    if (matchType == MatchType.DECOMPOSE || matchType == MatchType.ANY) {
      matchB = "any()";
    } else {
      matchB = "eq(" + paramName + ".t)";
    }
    return matchB;
  }
940215
def substitute_timestep(self, regex, timestep):
        

        # Make one change at a time, each change affects subsequent matches.
        timestep_changed = False
        while True:
            matches = re.finditer(regex, self.str, re.MULTILINE | re.DOTALL)
            none_updated = True
            for m in matches:
                if m.group(1) == timestep:
                    continue
                else:
                    self.str = (self.str[:m.start(1)] + timestep +
                                self.str[m.end(1):])
                    none_updated = False
                    timestep_changed = True
                    break

            if none_updated:
                break

        if not timestep_changed:
            sys.stderr.write('WARNING: no update with {0}.\n'.format(regex))