Fixed #27. Added support for rightTrim function

This commit is contained in:
Shekhar Gulati
2016-05-21 22:50:59 +05:30
parent 665cc8f32e
commit 18b0f0ae19
2 changed files with 18 additions and 0 deletions
+11
View File
@@ -801,6 +801,17 @@ public abstract class Strman {
return append(value, repeat(pad, length - value.length()));
}
/**
* Remove all spaces on right.
*
* @param value The String
* @return String without right boarders spaces.
*/
public static String rightTrim(final String value) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return value.replaceAll("\\s+$", "");
}
public static String decode(final String value, final int digits, final int radix) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return Arrays
+7
View File
@@ -612,4 +612,11 @@ public class StrmanTest {
assertThat(rightPad("10000", "0", 5), equalTo("10000"));
assertThat(rightPad("10000000", "0", 5), equalTo("10000000"));
}
@Test
public void rightTrim_shouldRemoveSpacesFromTheRight() throws Exception {
assertThat(rightTrim("strman "), equalTo("strman"));
assertThat(rightTrim(" strman"), equalTo(" strman"));
assertThat(rightTrim("strman"), equalTo("strman"));
}
}