mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-18 13:33:55 +00:00
Fixed #14. Added support for leftTrim function
This commit is contained in:
@@ -602,7 +602,16 @@ public abstract class Strman {
|
||||
return value.toLowerCase().lastIndexOf(needle.toLowerCase(), offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes all spaces on left
|
||||
*
|
||||
* @param value The input String
|
||||
* @return String without left border spaces
|
||||
*/
|
||||
public static String leftTrim(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);
|
||||
|
||||
@@ -475,4 +475,10 @@ public class StrmanTest {
|
||||
assertThat(lastIndexOf(value, "R", false), equalTo(11));
|
||||
assertThat(lastIndexOf(value, "T", false), equalTo(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void leftTrim_shouldRemoveSpacesOnLeft() throws Exception {
|
||||
assertThat(leftTrim(" strman"), equalTo("strman"));
|
||||
assertThat(leftTrim(" strman "), equalTo("strman "));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user