Python rstrip in Java

by GarciaPL on Friday 13 July 2018

Last time I was working on migration of some code from Python into Java and I was trying to find a corresponding code in Java for a function called rstrip in Python. So, below you can see a code written in Python and solution written in Java produced of course using Guava.

icb_code.rstrip("0")


CharMatcher trailingZeroMatcher = CharMatcher.is('0');
String trimmedInput = trailingZeroMatcher.trimTrailingFrom(input);