Fixed #32. Added support for split function

This commit is contained in:
Shekhar Gulati
2016-05-22 00:08:59 +05:30
parent 162b02bf98
commit 83539a99b9
+24 -1
View File
@@ -829,7 +829,7 @@ public abstract class Strman {
return value;
}
String[] words = value.split("\\W+");
String[] words = words(value);
StringJoiner result = new StringJoiner(" ");
int spaceCount = 0;
for (String word : words) {
@@ -843,6 +843,29 @@ public abstract class Strman {
return append(result.toString(), filler);
}
/**
* Alias to String split function. Defined only for completeness.
*
* @param value The input String
* @param regex The delimiting regular expression
* @return String Array
*/
public static String[] split(final String value, final String regex) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return value.split(regex);
}
/**
* Splits a String to words
*
* @param value The input String
* @return Words Array
*/
public static String[] words(final String value) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return value.split("\\W+");
}
public static String decode(final String value, final int digits, final int radix) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return Arrays