:param str s: multi-line string with tabs
    :param str replace: e.g. 4 spaces
    :rtype: str
326784
def replace_tab_indents(s, replace="    "):
    
    lines = s.splitlines(True)
    return "".join([replace_tab_indent(l, replace) for l in lines])
832840
private static Pattern replacePlaceHolders(String s) {
    s = Pattern.quote(s);
    return Pattern.compile(s.replaceAll("\\{\\d+\\}", "\\\\E.*\\\\Q"));
  }
835917
public static String replaceChar(String s, char c, String replacement)
  {
    int pos = s.indexOf(c);
    if (pos < 0) {
      return s;
    }
    StringBuilder sb = new StringBuilder(s.length() - 1 + replacement.length());
    int prevPos = 0;
    do {
      sb.append(s, prevPos, pos);
      sb.append(replacement);
      prevPos = pos + 1;
      pos = s.indexOf(c, pos + 1);
    } while (pos > 0);
    sb.append(s, prevPos, s.length());
    return sb.toString();
  }
327813
private static String replaceCharAt(String s, int pos, char c) {
		return s.substring(0, pos) + c + s.substring(pos + 1);
	}
927830
def string_to_identifier(s, white_space_becomes='_'):
    
    import re
    s = s.lower()
    s = re.sub(r"\s+", white_space_becomes, s) # replace whitespace with underscores
    s = re.sub(r"-", "_", s) # replace hyphens with underscores
    s = re.sub(r"[^A-Za-z0-9_]", "", s) # remove everything that's not a character, a digit or a _
    return s
1243758
def _substitute(self, str):
        
        if not self.attr.get("substitute",True):return str
        return self._regex.sub(lambda mo:
                self._reflections[mo.string[mo.start():mo.end()]],
                    str.lower())
895131
function replaceAll(str, find, replace) {
	let s = '',
		index,
		next;
	while (~(next = str.indexOf(find, index))) {
		s += str.substring(index, next) + replace;
		index = next + find.length;
	}
	return s + str.substring(index);
}
769237
function cleanStr(s, rs){ //(s: string (string), rs: remove spaces (bool))
	if(s){
		s = s.replace(/"/g, '').trim();
		if(rs) s = s.replace(/ /g, '');
	}
	return s;
}
602741
public final String replaceAll(String s, char replacementCharacter) {
    final StringBuilder sb = new StringBuilder();

    for (int offset = 0; offset < s.length(); ) {
      final int codePoint = s.codePointAt(offset);
      if (matches(codePoint)) {
        sb.append(replacementCharacter);
      } else {
        sb.appendCodePoint(codePoint);
      }
      offset += Character.charCount(codePoint);
    }

    return sb.toString();
  }
299825
def escape_tabs_newlines(s: str) -> str:
    
    if not s:
        return s
    s = s.replace("\\", r"\\")  # replace \ with \\
    s = s.replace("\n", r"\n")  # escape \n; note ord("\n") == 10
    s = s.replace("\r", r"\r")  # escape \r; note ord("\r") == 13
    s = s.replace("\t", r"\t")  # escape \t; note ord("\t") == 9
    return s
776995
private static function str_replace($s,$r,$str)
    {
        if(!is_array($s)){
            $s = '!'.preg_quote($s,'!').'!u';
        }else{
            foreach ($s as $k => $v) {
                $s[$k] = '!'.preg_quote($v).'!u';
            }
        }
        return preg_replace($s,$r,$str);
    }
812796
def from_string(cls, s):
        
        def _qstrip(s):
            return s[1:-1]  # remove assumed quote characters
        tokens = []
        for match in _yy_re.finditer(s):
            d = match.groupdict()
            lnk, pos = None, []
            if d['lnkfrom'] is not None:
                lnk = Lnk.charspan(d['lnkfrom'], d['lnkto'])
            if d['pos'] is not None:
                ps = d['pos'].strip().split()
                pos = list(zip(map(_qstrip, ps[::2]), map(float, ps[1::2])))
            tokens.append(
                YyToken(
                    int(d['id']),
                    int(d['start']),
                    int(d['end']),
                    lnk,
                    list(map(int, d['paths'].strip().split())),
                    _qstrip(d['form']),
                    None if d['surface'] is None else _qstrip(d['surface']),
                    int(d['ipos']),
                    list(map(_qstrip, d['lrules'].strip().split())),
                    pos
                )
            )
        return cls(tokens)
314939
public static String stripSpaces(String s)
    {
        StringBuffer buff = new StringBuffer();
        for(int i = 0; i < s.length(); i++)
        {
            char c = s.charAt(i);
            if(c != ' ')
                buff.append(c);
        }
        return buff.toString();
    }
754534
def multi_replace(instr, search_list=[], repl_list=None):
    
    repl_list = [''] * len(search_list) if repl_list is None else repl_list
    for ser, repl in zip(search_list, repl_list):
        instr = instr.replace(ser, repl)
    return instr
1151600
public static function replacePrefix(string $s, string $search, string $replacement = ''): string
	{
		if (strncmp($s, $search, strlen($search)) === 0) {
			$s = $replacement . substr($s, strlen($search));
		}

		return $s;
	}
1375006
public String replace(String str, String regex, String replace) {
		if (str == null)
			return "";
		if (regex == null)
			return str;
		if(replace == null) replace = "";
		return str.replaceAll(regex, replace);
	}
563277
def clean_whitespace(statement):
    
    import re

    # Replace linebreaks and tabs with spaces
    statement.text = statement.text.replace('\n', ' ').replace('\r', ' ').replace('\t', ' ')

    # Remove any leeding or trailing whitespace
    statement.text = statement.text.strip()

    # Remove consecutive spaces
    statement.text = re.sub(' +', ' ', statement.text)

    return statement