public static string Replace(java.lang.String str, string oldStr, string newStr) { ThrowHelper.ThrowIfNull(oldStr); int lenOld = ((java.lang.String)(object) oldStr).length(); if (lenOld == 0) { throw new System.ArgumentException(); } int idx1 = str.indexOf(oldStr, 0); if (idx1 == -1) { return((string)(object)str); } int idx0 = 0; int len = str.length(); var sb = new java.lang.StringBuilder(); for (;;) { sb.append(str.substring(idx0, idx1)); if (newStr != null) { sb.append(newStr); } if ((idx0 = idx1 + lenOld) >= len || (idx1 = str.indexOf(oldStr, idx0)) == -1) { sb.append(str.substring(idx0)); return(sb.ToString()); } } }
private static void SplitCharacter(java.lang.String str, int length, java.util.ArrayList list, int maxCount, bool omit, char[] anyOf) { int listCount = 0; int lastIndex = -1; for (int index = 0; index < length; index++) { if (!CharAtIsAnyOf(str, index, anyOf)) { continue; } if (index == ++lastIndex && omit) { continue; } if (++listCount == maxCount) { list.add(str.substring(lastIndex)); return; } list.add(str.substring(lastIndex, index)); lastIndex = index; } if (length != ++lastIndex || !omit) { list.add(str.substring(lastIndex)); } }
public static int CompareOrdinal(java.lang.String strA, int indexA, java.lang.String strB, int indexB, int length) { if (object.ReferenceEquals(strA, strB)) { return(0); } if (strA == null) { return(-1); } if (strB == null) { return(1); } int endIndexA, endIndexB; if (indexA < 0 || (endIndexA = indexA + length) > strA.length() || indexB < 0 || (endIndexB = indexB + length) > strB.length()) { throw new System.ArgumentOutOfRangeException(); } return(((java.lang.String)(object) strA.substring(indexA, endIndexA)) .compareTo((java.lang.String)(object) strB.substring(indexB, endIndexB))); }
private static void SplitString(java.lang.String str, int length, java.util.ArrayList list, int maxCount, bool omit, java.lang.String[] anyOfStr) { int anyOfNum = anyOfStr.Length; char[] anyOfChar = new char[anyOfNum]; for (int index = 0; index < anyOfNum; index++) { var s = anyOfStr[index]; anyOfChar[index] = (s != null && s.length() > 0) ? s.charAt(index) : '\0'; } int listCount = 0; int lastIndex = 0; for (int index = 0; index < length;) { int len = StrAtIsAnyOf(str, index, anyOfNum, anyOfChar, anyOfStr); if (len == -1) { index++; } else { if (index != lastIndex || !omit) { if (++listCount == maxCount) { list.add(str.substring(lastIndex)); return; } list.add(str.substring(lastIndex, index)); } lastIndex = (index += len); } } if (length != lastIndex || !omit) { list.add(str.substring(lastIndex)); } }
public static string TrimWhiteSpace(java.lang.String str, bool trimStart, bool trimEnd) { int n = str.length(); int i = 0; if (trimStart) { while (i < n && Char.IsWhiteSpace(str.charAt(i))) { i++; } } if (trimEnd) { while (n-- > i && Char.IsWhiteSpace(str.charAt(n))) { ; } n++; } return(str.substring(i, n)); }
public static string Substring(java.lang.String str, int idx, int len) { ThrowIfBadIndexOrCount(str, idx, len); return(str.substring(idx, idx + len)); }
public static string Substring(java.lang.String str, int idx) { ThrowIfBadIndex(str, idx); return(str.substring(idx)); }