public class StringUtil extends Object
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
concat(String separator,
String... parts) |
static String |
concatStrings(String part1,
String separator,
String part2)
Concatenates two strings, if specified, uses the separator in between two strings.
|
static int |
countRegex(String string,
String regex)
Counts the number of characters that the specified regexes will affect in the specified string.
|
static String |
hide(String string) |
static String |
hide(String string,
int mode)
Hides the string based on the mode given.
|
static String |
hideAll(String message,
Collection<String> collection)
Hide all characters matching the given Regular Expression.
|
static String |
hideAll(String message,
Collection<String> collection,
int mode)
Hide all characters matching the given Regular Expression.
|
static String |
hideAll(String inputString,
String regex) |
static String |
hideAll(String inputString,
String regex,
int mode)
Hides the input string according to the given regex and mode.
|
static String |
hideFirstHalf(String inputString,
String regex)
Hides the first half of the string.
|
static String |
lcFirst(String input)
Turns the first Char into lower case.
|
static String |
safeCollectionToString(Collection<?> collection) |
static List<String> |
split(String input)
Splits a string into a list of substrings using default delimiter ','.
|
static List<String> |
split(String input,
String delim)
Splits a string into an array of substrings using specified delimiters.
|
static Stream<String> |
splitToStream(String input)
Splits a string into a stream of substrings using default delimiter ','.
|
static Stream<String> |
splitToStream(String input,
String delim)
Splits a string into a stream of substrings using specified delimiters.
|
static String |
ucFirst(String input)
Turns the first Char into upper case.
|
public static String concatStrings(String part1, String separator, String part2)
Example:
String a = "We"; String b = "Frank"; String separator = "Are"; String res = StringUtil.concatStrings(a, separator, b); System.out.println(res); // prints "WeAreFrank"
part1
- First stringseparator
- Specified separatorpart2
- Second stringpublic static String hide(String string)
hide(String)
public static String hide(String string, int mode)
Example:
String a = "test"; String res = StringUtil.hide(a, 1); System.out.println(res) // prints "t**t"
public static String hideFirstHalf(String inputString, String regex)
hideAll(String, String, int)
public static String hideAll(String message, Collection<String> collection)
hideAll(String, Collection, int)
public static String hideAll(String message, Collection<String> collection, int mode)
hideAll(String, String, int)
public static String hideAll(String inputString, String regex)
hideAll(String, String, int)
public static String hideAll(String inputString, String regex, int mode)
public static int countRegex(String string, String regex)
String s = "12ab34"; String regex = "\\d"; int regexCount = StringUtil.countRegex(s, regex); // regexCount gives out 4
public static String safeCollectionToString(Collection<?> collection)
@Nonnull public static List<String> split(@Nullable String input)
input
- the string to split, can be null.List
of strings. An empty list if the input was null.@Nonnull public static Stream<String> splitToStream(@Nullable String input)
input
- the string to split, can be null.Stream
of strings. An empty stream if the input was null.@Nonnull public static List<String> split(@Nullable String input, @Nonnull String delim)
input
- the string to split, can be null.delim
- the delimiters to split the string byList
of strings. An empty list if the input was null.@Nonnull public static Stream<String> splitToStream(@Nullable String input, @Nonnull String delim)
input
- the string to split, can be null.delim
- the delimiters to split the string byCopyright © 2023 Frank!Framework. All rights reserved.