mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-20 06:24:05 +00:00
Fixed #27. Added support for rightTrim function
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user