diff --git a/src/main/java/strman/Strman.java b/src/main/java/strman/Strman.java index c970560..f608855 100644 --- a/src/main/java/strman/Strman.java +++ b/src/main/java/strman/Strman.java @@ -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