/* to replace chars between c_bra and c_ket in current by the
chars in s.
346400
protected int replace_s(int c_bra, int c_ket, String s)
    {
	int adjustment = s.length() - (c_ket - c_bra);
	current.replace(c_bra, c_ket, s);
	limit += adjustment;
	if (cursor >= c_ket) cursor += adjustment;
	else if (cursor > c_bra) cursor = c_bra;
	return adjustment;
    }
120530
private String addRemChars(String pstrSrc)
    {
        int intLen  = 2;
        int intPos  = 0;
        int intPrev = 0;

        String strLeft  = null;
        String strRight = null;

        if (pstrSrc == null) return null;
        while (intPos >= 0)
        {
            intLen = 2;
            intPos = pstrSrc.indexOf("\r\n", intPrev);
            if (intPos < 0)
            {
                intLen = 1;
                intPos = pstrSrc.indexOf("\n", intPrev);
                if (intPos < 0) intPos = pstrSrc.indexOf("\r", intPrev);
            }
            if (intPos == 0)
            {
                pstrSrc = ";\r\n" + pstrSrc.substring(intPos + intLen);
                intPrev = intPos + intLen + 1;
            }
            else if (intPos > 0)
            {
                strLeft = pstrSrc.substring(0, intPos);
                strRight = pstrSrc.substring(intPos + intLen);
                if (strRight == null)
                    pstrSrc = strLeft;
                else if (strRight.length() == 0)
                    pstrSrc = strLeft;
                else
                    pstrSrc = strLeft + "\r\n;" + strRight;
                intPrev = intPos + intLen + 1;
            }
        }
        if (!pstrSrc.substring(0, 1).equals(";"))
            pstrSrc = ";" + pstrSrc;
        pstrSrc = pstrSrc + "\r\n";
        return pstrSrc;
    }
381315
public void replace(CharSequence text, Appendable out) throws IOException
    {
        int idx = CharSequences.indexOf(text, "${");
        if (idx != -1)
        {
            out.append(text.subSequence(0, idx));
            int end = findEnd(text, idx+2);
            String key = replace(text.subSequence(idx+2, end));
            out.append(map(key));
            out.append(replace(text.subSequence(end+1, text.length())));
            
        }
        else
        {
            out.append(text);
        }
    }
787328
function underscoreToCamel (str) {
    str = str.charAt(0).toUpperCase() + str.slice(1);
    return str.replace(/\_(.)/g, function (x, chr) {
      return chr.toUpperCase();
    })
  }
641015
def char_to_a(char: "\s", strip: true)
      escaped = char.regexp_escape
      split(/(?<!\\)#{escaped}/).map do |v|
        strip ? v.gsub(/\\#{escaped}/, char) : v
      end
    end
1047604
def _backward_delete_char(text, pos):
    """"""
    if pos == 0:
        return text, pos
    return text[:pos - 1] + text[pos:], pos - 1
525637
private static String replaceInvalidChars(String substring) {
        StringBuilder builder = new StringBuilder();
        for(char c : substring.toCharArray()) {
            if(c < 32) {
                builder.append('.');
            } else {
                builder.append(c);
            }
        }
        return builder.toString();
    }
319538
function replaceBadCharacters( text ) {
  var i, repl;
  for ( i = 0; i < rLen; i++ ) {
    repl = replacements[i];
    text = text.replace( repl[0], repl[1] );
  }
  return text;
}
1043572
private static CharSequence reverse(CharSequence s) {
    int length = s.length();
    if (length <= 1) {
      return s;
    }

    char[] buffer = new char[length];
    buffer[0] = s.charAt(length - 1);

    for (int i = 1; i < length; i++) {
      buffer[i] = s.charAt(length - 1 - i);
      if (Character.isSurrogatePair(buffer[i], buffer[i - 1])) {
        swap(buffer, i - 1, i);
      }
    }

    return new String(buffer);
  }
1119866
public void replaceStr(Pointer str, int len, ScalarStyle style) {
        Data.Str s = (Data.Str)data;
        s.ptr = Pointer.create(new byte[len], 0);
        s.len = len;
        s.style = style;
        str.memcpy(s.ptr, len);
    }
324713
public AsciiString replace(char oldChar, char newChar) {
        if (oldChar > MAX_CHAR_VALUE) {
            return this;
        }

        final byte oldCharAsByte = c2b0(oldChar);
        final byte newCharAsByte = c2b(newChar);
        final int len = offset + length;
        for (int i = offset; i < len; ++i) {
            if (value[i] == oldCharAsByte) {
                byte[] buffer = PlatformDependent.allocateUninitializedArray(length());
                System.arraycopy(value, offset, buffer, 0, i - offset);
                buffer[i - offset] = newCharAsByte;
                ++i;
                for (; i < len; ++i) {
                    byte oldValue = value[i];
                    buffer[i - offset] = oldValue != oldCharAsByte ? oldValue : newCharAsByte;
                }
                return new AsciiString(buffer, false);
            }
        }
        return this;
    }
605364
public static String normalizeCharset(String s) {
        String n = CHARSETS.get(s);
        return (n == null) ? s : n;
    }
363998
private static String modify(final String str, final String[] set, final boolean expect) {
        final CharSet chars = CharSet.getInstance(set);
        final StringBuilder buffer = new StringBuilder(str.length());
        final char[] chrs = str.toCharArray();
        for (final char chr : chrs) {
            if (chars.contains(chr) == expect) {
                buffer.append(chr);
            }
        }
        return buffer.toString();
    }
808083
def convert_string(string, chars=None):
    """"""
    if chars is None:
        chars = [',', '.', '-', '/', ':', '  ']

    for ch in chars:
        if ch in string:
            string = string.replace(ch, ' ')
    return string
548142
public String replace(CharSequence text, CharSequence replacement)
    {
        try
        {
            if (text.length() == 0)
            {
                if (acceptEmpty)
                {
                    return "";
                }
            }
            CharArrayWriter caw = new CharArrayWriter();
            InputReader reader = Input.getInstance(text);
            ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(replacement);
            replace(reader, caw, fsp);
            return caw.toString();
        }
        catch (IOException ex)
        {
            throw new IllegalArgumentException("can't happen", ex);
        }
    }
948703
@Override
    public FastStr replace(char oldChar, char newChar) {
        if (oldChar != newChar) {
            char[] val = this.buf; /* avoid getfield opcode */
            int len = length();
            int i = begin - 1;

            while (++i < end) {
                if (val[i] == oldChar) {
                    break;
                }
            }
            if (i < end) {
                char buf[] = new char[len];
                for (int j = begin; j < i; j++) {
                    buf[j - begin] = val[j];
                }
                while (i < end) {
                    char c = val[i];
                    buf[i - begin] = (c == oldChar) ? newChar : c;
                    i++;
                }
                return new FastStr(buf, 0, len);
            }
        }
        return this;
    }
651634
static String normalize(String s) {
        StringBuilder sb = new StringBuilder();
        boolean changed = false;
        boolean lastCharWasWS = false;
        final int len = s.length();
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if (Character.isWhitespace(c)) {
                if (!lastCharWasWS) {
                    sb.append(SPACE);
                    changed |= c != SPACE;
                } else {
                    changed = true;
                }
                lastCharWasWS = true;
            } else {
                sb.append(c);
                lastCharWasWS = false;
            }
        }
        return changed ? sb.toString() : s;
    }