Replaces the grist of a string by a new one.
        Returns the string with the new grist.
438206
def replace_grist (features, new_grist):
    
    assert is_iterable_typed(features, basestring) or isinstance(features, basestring)
    assert isinstance(new_grist, basestring)
    # this function is used a lot in the build phase and the original implementation
    # was extremely slow; thus some of the weird-looking optimizations for this function.
    single_item = False
    if isinstance(features, str):
        features = [features]
        single_item = True

    result = []
    for feature in features:
        # '<feature>value' -> ('<feature', '>', 'value')
        # 'something' -> ('something', '', '')
        # '<toolset>msvc/<feature>value' -> ('<toolset', '>', 'msvc/<feature>value')
        grist, split, value = feature.partition('>')
        # if a partition didn't occur, then grist is just 'something'
        # set the value to be the grist
        if not value and not split:
            value = grist
        result.append(new_grist + value)

    if single_item:
        return result[0]
    return result
1280862
function (text, replacements) {
        'use strict';
        var keys = getKeysFromTemplate(text),//Object.keys(replacements),
            len = keys.length,
            i = 0,
            key,
            value;
        while (i < len) {
            key = keys[i];
            if (key.indexOf('.') !== -1) {
                value = getNestedValue(replacements, key);
            } else {
                value = replacements[key];
            }
            if (value) {
                text = text.split('{' + key + '}').join(value);
            }
            i += 1;
        }
        return text;
    }
1075266
private static void replaceThis(Node expectedGetprop, Node replacement) {
    Node leftChild = expectedGetprop.getFirstChild();
    if (leftChild.isThis()) {
      expectedGetprop.replaceChild(leftChild, replacement);
    } else {
      replaceThis(leftChild, replacement);
    }
  }
278239
def substitute(ctx, text, old_text, new_text, instance_num=-1):
    
    text = conversions.to_string(text, ctx)
    old_text = conversions.to_string(old_text, ctx)
    new_text = conversions.to_string(new_text, ctx)

    if instance_num < 0:
        return text.replace(old_text, new_text)
    else:
        splits = text.split(old_text)
        output = splits[0]
        instance = 1
        for split in splits[1:]:
            sep = new_text if instance == instance_num else old_text
            output += sep + split
            instance += 1
        return output
757656
function replacePlaceholder(str, value, _state) {
	if (typeof str === 'string') {
		const ranges = findUnescapedTokens(str, placeholder);
		if (ranges.length) {
			if (_state) {
				_state.replaced = true;
			}

			str = replaceRanges(str, ranges, value);
		}
	}

	return str;
}
850037
function applyReplacements(str, replacements) {
    var result = "",
        replacement,
        i;

    for (i = 0; i < replacements.length; i++) {
        replacement = replacements[i];
        if (replacement) {
            result += replacement.newStr;
            i += replacement.oldStr.length - 1;
        } else {
            result += str.charAt(i);
        }
    }

    result += str.substr(i, str.length);

    return result;
}
375634
def replace(value, arg):
    

    replacement = arg.split('|')
    try:
        return value.replace(replacement[0], replacement[1])
    except:
        return value
1374757
private String stringReplace(final String source, final String find, final String replace) {
    if (source == null || find == null || replace == null)
      return source;
    final int index = source.indexOf(find);
    if (index == -1)
      return source; // no occurence, don't do anything;
    if (index == 0)
      return replace + source.substring(find.length());
    return source.substring(0, index) + replace + source.substring(index + find.length());
  }
664029
def replace(input, **params):
    
    PARAM_REPLACE_LIST = 'replace'
    REPLACE_FIELD = 'field'
    REPLACE_FIND_VALUE = 'value.to_find'
    REPLACE_WITH_VALUE = 'value.replace_with'

    replace_list = params.get(PARAM_REPLACE_LIST)
    for row in input:
        for replace in replace_list:
            if row[replace[REPLACE_FIELD]] == replace[REPLACE_FIND_VALUE]:
                row[replace[REPLACE_FIELD]] = replace[REPLACE_WITH_VALUE]
    return input
31296
public void replace (String... replace)
    {
        HashSet<String> toAdd = Sets.newHashSet();
        Iterator<String> i = _imports.iterator();
        while (i.hasNext()) {
            String name = i.next();
            for (int j = 0; j < replace.length; j += 2) {
                if (name.equals(replace[j])) {
                    toAdd.add(replace[j + 1]);
                    i.remove();
                    break;
                }
            }
        }
        _imports.addAll(toAdd);
    }
36760
public Tuple3<ReadOnlyStyledDocument<PS, SEG, S>, RichTextChange<PS, SEG, S>, MaterializedListModification<Paragraph<PS, SEG, S>>> replace(
            Replacement<PS, SEG, S> replacement) {
        return replace(replacement.getStart(), replacement.getEnd(), replacement.getDocument());
    }
502525
public static String replace(String string, char oldChar, char newChar) {
        return checkNull(string).replace(oldChar, newChar);
    }
205922
def replace(self, old, new, variable_set=None, leaf_operation=None):   # pylint:disable=unused-argument
        
        self._check_replaceability(old, new)
        replacements = {old.cache_key: new}
        return self.replace_dict(replacements, variable_set=old.variables)
1147595
def replace_symbol(text, replacement_text="", is_replace_consecutive_chars=False, is_strip=False):
    

    try:
        new_text = __RE_SYMBOL.sub(replacement_text, preprocess(text))
    except (TypeError, AttributeError):
        raise TypeError("text must be a string")

    if not replacement_text:
        return new_text

    if is_replace_consecutive_chars:
        new_text = re.sub("{}+".format(re.escape(replacement_text)), replacement_text, new_text)

    if is_strip:
        new_text = new_text.strip(replacement_text)

    return new_text
402363
public static String replace(String string, Map<String,String> ht)
    {
        return Utility.replace(new StringBuilder(string), ht).toString();
    }
1201792
private V replaceValue(Node<V> node, V newValue) {
        // Note: a node is terminal if it already has a value
	if (node.isTerminal()) {
	    V old = node.value;
	    node.value = newValue;
	    return old;
	}
	// the node wasn't already a terminal node (i.e. this char sequence is a
	// substring of an existing sequence), assign it a value
	else {
	    node.value = newValue;
	    size++;
	    return null; // no old value
	}
    }
1003551
def _replace(self, **kargs):
        
        fields = {f.name: getattr(self, f.name)
                  for f in self._struct}
        fields.update(kargs)
        return type(self)(**fields)