/* Remove the trailing zeros from a string.
*
504679
function removeTrailingZeros(str) {
  if (typeof str != 'string') throw new Error('in removeTrailingZeros, data type mismatch');

  let iNonZero = -1;
  for (let i = str.length - 1; i >= 0; i--) {
    if (charToVal(str[i]) != 0) {
      iNonZero = i; // index of the first nonzero digit from the right.
      break;
    }
  }
  str = str.slice(0, iNonZero + 1); // if 'str' is entirely zeros or is the empty string, gives ''.

  return str;
}
1084937
public void removeTrailingWhitespaces()
    {
        int last = -1;
        for (int i = text.length() - 1; i >= 0; i--)
        {
            if (isWhitespace(text.charAt(i)))
                last = i;
            else
                break;
        }
        if (last != -1)
        {
            text = text.substring(0, last);
            textStart = 0;
            textEnd = last;
        }
    }
857901
function( string ){
      string = string.replace(/([A-Z])/g, function($1){return "-"+$1.toLowerCase();});
      // remove first dash
      return  ( string.charAt( 0 ) == '-' ) ? string.substr(1) : string;
    }
732480
private static String stripLeadingNonNumeric(String str) {
        for (int x = 0; x < str.length(); x++) {
            if (Character.isDigit(str.codePointAt(x))) {
                return str.substring(x);
            }
        }
        return null;
    }
418765
function unPrefix(s, prefix) {
  s = str(s);
  if (!prefix) return s;
  if (s.slice(0, prefix.length) === prefix) return s.slice(prefix.length);
  return s;
}
753467
private function removeTrailingZeroesIfNeeded()
    {
        $exponent = $this->getExponent();
        $coefficient = $this->getCoefficient();

        // trim trailing zeroes from the fractional part
        // for example 1000e-1 => 100.0
        if (0 < $exponent && '0' === substr($coefficient, -1)) {
            $fractionalPart = $this->getFractionalPart();
            $trailingZeroesToRemove = 0;
            for ($i = $exponent - 1; $i >= 0; $i--) {
                if ('0' !== $fractionalPart[$i]) {
                    break;
                }
                $trailingZeroesToRemove++;
            }

            if ($trailingZeroesToRemove > 0) {
                $this->coefficient = substr($coefficient, 0, -$trailingZeroesToRemove);
                $this->exponent = $exponent - $trailingZeroesToRemove;
            }
        }
    }
1024256
public static String trimSubstring(String string, int pos, int limit) {
    int start = skipLeadingAsciiWhitespace(string, pos, limit);
    int end = skipTrailingAsciiWhitespace(string, start, limit);
    return string.substring(start, end);
  }
1330258
public final String trimFrom(String s) {
    int first;
    int last;

    // removes leading matches
    for (first = 0; first < s.length(); ) {
      final int codePoint = s.codePointAt(first);
      if (!matches(codePoint)) {
        break;
      }
      first += Character.charCount(codePoint);
    }

    //remove trailing matches
    for (last = s.length() - 1; last >= first; --last) {
      if (Character.isLowSurrogate(s.charAt(last))) {
        --last;
      }
      if (!matches(s.codePointAt(last))) {
        break;
      }
    }

    return s.substring(first, last + 1);
  }
823751
public static function remove_trailing($string, $trailing_string)
    {
        if (StringTool :: end_with($string, $trailing_string))
        {
            return substr($string, 0, strlen($string) - strlen($trailing_string));
        }
        else
        {
            return $string;
        }
    }
779036
func floatStringToNs(s string) (int64, error) {
	const zeros = "000000000"
	if point := strings.IndexRune(s, '.'); point >= 0 {
		tail := s[point+1:]
		if fill := 9 - len(tail); fill < 0 {
			tail = tail[:9]
		} else {
			tail += zeros[:fill]
		}
		s = s[:point] + tail
	} else if len(s) > 0 { // Make sure empty string produces an error
		s += zeros
	}
	return strconv.ParseInt(s, 10, 64)
}
904396
public static String trimTrailing(String str) {
        if (str == null) {
            return null;
        }
        int len = str.length();
        for (; len > 0; len--) {
            if (!Character.isWhitespace(str.charAt(len - 1))) {
                break;
            }
        }
        return str.substring(0, len);
    }
1276812
function trim( str, chr ){
	if ( !chr ){
		chr = '\\s';
	}
	return str.replace( new RegExp('^'+chr+'+|'+chr+'+$','g'), '' );
}
644971
protected static void removeTralingZeros( StringBuilder sb ) {
        int endIndex = sb.length();
        if (endIndex > 0) {
            --endIndex;
            int index = endIndex;
            while (sb.charAt(index) == '0') {
                --index;
            }
            if (index < endIndex) sb.delete(index + 1, endIndex + 1);
        }
    }
860732
@Deprecated
	public static String removeChars(String S, char[] chars) {
		int pos;
		while((pos=indexOf(S, chars))!=-1) S=S.substring(0,pos)+S.substring(pos+1);
		return S;
	}
1250156
static int trimSpaces(char[] chars, int len) {
		// leading and trailing #x20's are removed
		int newLen = len;

		// leading
		while (newLen > 0 && chars[0] == ' ') {
			// eliminate one leading space
			shiftLeft(chars, 0, newLen);
			newLen--;
		}
		// trailing
		int i = newLen - 1;
		while (i >= 0 && chars[i] == ' ') {
			// eliminate one trailing space
			newLen--;
			i--;
		}

		return newLen;
	}
1350148
String trim(String string) {
        BaseFont ft = font.getFont();
        if (ft.getFontType() == BaseFont.FONT_TYPE_CJK && ft.getUnicodeEquivalent(' ') != ' ') {
            while (string.endsWith("\u0001")) {
                string = string.substring(0, string.length() - 1);
            }
        }
        else {
            while (string.endsWith(" ") || string.endsWith("\t")) {
                string = string.substring(0, string.length() - 1);
            }
        }
        return string;
    }
938815
func TrailingZeros(trits Trits) int64 {
	z := int64(0)
	for i := len(trits) - 1; i >= 0 && trits[i] == 0; i-- {
		z++
	}
	return z
}