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 |
replace(String source,
String from,
String to)
Deprecated.
Use instead
String.replace(CharSequence, CharSequence) .
Example: String a = "WeAreFrank"; String res = StringUtil.replace(a, "WeAre", "IAm"); System.out.println(res); // prints "IAmFrank" |
@Deprecated public static String replace(String source, String from, String to)
String.replace(CharSequence, CharSequence)
.
Example:
String a = "WeAreFrank"; String res = StringUtil.replace(a, "WeAre", "IAm"); System.out.println(res); // prints "IAmFrank"
source
- is the original stringfrom
- is the string to be replacedto
- is the string which will used to replacepublic 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)
Copyright © 2023 Frank!Framework. All rights reserved.