Expand the string using the format replace pattern or function.
336846
def expandf(m, format):  # noqa A002
    """"""

    _assert_expandable(format, True)
    return _apply_replace_backrefs(m, format, flags=FORMAT)
1209553
String replace(String source) {
        if (source == null)
            return null;
        Matcher m = PATTERN.matcher(source);
        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            String var = m.group(1);
            String value = values.getProperty(var);
            String replacement = (value != null) ? replace(value) : "";
            m.appendReplacement(sb, Matcher.quoteReplacement(replacement));
        }
        m.appendTail(sb);
        return sb.toString();
    }
601189
function replace(regex, source, options) {
  var valueOrFn = getValueOrMatchFn(options.value)
  source.replace(regex, function () { return '' })
  return source.replace(regex, valueOrFn)
}
777173
function expand(str, opts) {
  opts = opts || {};

  if (typeof str !== 'string') {
    throw new TypeError('expand-object expects a string.');
  }

  if (!/[.|:=]/.test(str) && /,/.test(str)) {
    return toArray(str);
  }

  var m;
  if ((m = /(\w+[:=]\w+\.)+/.exec(str)) && !/[|,+]/.test(str)) {
    var val = m[0].split(':').join('.');
    str = val + str.slice(m[0].length);
  }

  var arr = splitString(str, '|');
  var len = arr.length, i = -1;
  var res = {};

  if (isArrayLike(str) && arr.length === 1) {
    return expandArrayObj(str, opts);
  }

  while (++i < len) {
    var val = arr[i];
    // test for `https://foo`
    if (/\w:\/\/\w/.test(val)) {
      res[val] = '';
      continue;
    }

    var re = /^((?:\w+)\.(?:\w+))[:.]((?:\w+,)+)+((?:\w+):(?:\w+))/;
    var m = re.exec(val);
    if (m && m[1] && m[2] && m[3]) {
      var arrVal = m[2];
      arrVal = arrVal.replace(/,$/, '');
      var prop = arrVal.split(',');
      prop = prop.concat(toObject(m[3]));
      res = set(res, m[1], prop);
    } else if (!/[.,\|:=]/.test(val)) {
      res[val] = opts.toBoolean ? true : '';
    } else {
      res = expandObject(res, val, opts);
    }
  }
  return res;
}
836072
function formatStr(str, values) {
    values = values || {};

    if (typeof str !== 'string') {
        return str;
    }

    return str.replace(FORMAT_REGEXP, (m0, m1, m2) => (m1 === '%' ? "%{" + m2 + "}" : values[m2]));
}
650754
def _expand_formatting_rule(rule, national_prefix):
    
    if rule is None:
        return None
    if national_prefix is None:
        national_prefix = u("")
    rule = re.sub(u(r"\$NP"), national_prefix, rule)
    rule = re.sub(u(r"\$FG"), u("$1"), rule)
    return rule
558132
function expand(template, data) {
    if (template.indexOf("{{") >= 0) {
        let ast = myna.parsers.mustache(template);
        let lines = expandAst(ast, data);
        return lines.join("");
    } 
    else {
        return template;
    }
}
204156
def _assert_expandable(repl, use_format=False):
    """"""

    if isinstance(repl, ReplaceTemplate):
        if repl.use_format != use_format:
            if use_format:
                raise ValueError("Replace not compiled as a format replace")
            else:
                raise ValueError("Replace should not be compiled as a format replace!")
    elif not isinstance(repl, (str, bytes)):
        raise TypeError("Expected string, buffer, or compiled replace!")
1138370
def replace(input, string, replacement = ''.freeze)
      input.to_s.gsub(string.to_s, replacement.to_s)
    end
807574
private String stringReplace(String text, String target, String replacement) {
		return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(
				text).replaceAll(replacement);
	}
640780
def modify_pattern(self, pattern, group):
        """"""
        pattern = group_regex.sub(r'?P<{}_\1>'.format(self.name), pattern)
        return r'(?P<{}>{})'.format(group, pattern)
127435
def _expand1(instring, noerror):
    """"""

    # first expand names in parentheses
    # note this works on nested names too, expanding from the
    # inside out (just like IRAF)
    mm = __re_var_paren.search(instring)
    while mm is not None:
        # remove embedded dollar signs from name
        varname = mm.group('varname').replace('$','')
        if defvar(varname):
            varname = envget(varname)
        elif noerror:
            varname = ""
        else:
            raise ValueError("Undefined variable `%s' in string `%s'" %
                             (varname, instring))

        instring = instring[:mm.start()] + varname + instring[mm.end():]
        mm = __re_var_paren.search(instring)
    # now expand variable name at start of string
    mm = __re_var_match.match(instring)
    if mm is None:
        return instring
    varname = mm.group('varname')
    if varname in ['', ' ', None]:
        mm = __re_var_match2.match(instring)
        varname = mm.group('varname')

    if defvar(varname):
        # recursively expand string after substitution
        return _expand1(envget(varname) + instring[mm.end():], noerror)
    elif noerror:
        return _expand1(varname + instring[mm.end():], noerror)
    else:
        raise ValueError("Undefined variable `%s' in string `%s'" %
                         (varname, instring))
1001723
public String expand() throws VariableExpansionException
    {
        String template = getTemplate();
        for (Expression expression : expressions)
        {
            final String replacement = expressionReplacementString(expression, false);
            template = template.replaceAll(expression.getReplacementPattern(), replacement);
        }
        return template;
    }
575169
def subfn(pattern, format, string, *args, **kwargs):  # noqa A002
    """"""

    flags = args[4] if len(args) > 4 else kwargs.get('flags', 0)
    is_replace = _is_replace(format)
    is_string = isinstance(format, (str, bytes))
    if is_replace and not format.use_format:
        raise ValueError("Compiled replace is not a format object!")

    pattern = compile_search(pattern, flags)
    rflags = FORMAT if is_string else 0
    return _regex.subn(
        pattern, (compile_replace(pattern, format, flags=rflags) if is_replace or is_string else format), string,
        *args, **kwargs
    )
344116
def _single_replace(self, to_replace, method, inplace, limit):
    
    if self.ndim != 1:
        raise TypeError('cannot replace {0} with method {1} on a {2}'
                        .format(to_replace, method, type(self).__name__))

    orig_dtype = self.dtype
    result = self if inplace else self.copy()
    fill_f = missing.get_fill_func(method)

    mask = missing.mask_missing(result.values, to_replace)
    values = fill_f(result.values, limit=limit, mask=mask)

    if values.dtype == orig_dtype and inplace:
        return

    result = pd.Series(values, index=self.index,
                       dtype=self.dtype).__finalize__(self)

    if inplace:
        self._update_inplace(result._data)
        return

    return result
415950
function expand(url, params, variables) {

    var tmpl = parse(url), expanded = tmpl.expand(params);

    if (variables) {
        variables.push.apply(variables, tmpl.vars);
    }

    return expanded;
}
1325647
def expand_template(template, value):
    
    value = wrap(value)
    if is_text(template):
        return _simple_expand(template, (value,))

    return _expand(template, (value,))