public class StringUtils extends Object
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
hasText(String string) |
static String |
substringAfterLast(String str,
String separator)
Gets the substring after the last occurrence of a separator.
|
static String |
substringBeforeLast(String str,
String separator)
Gets the substring before the last occurrence of a separator.
|
public static boolean hasText(String string)
public static String substringBeforeLast(String str, String separator)
Gets the substring before the last occurrence of a separator. The separator is not returned.
A null
string input will return null
. An empty ("")
string input will return the empty string. An empty or null
separator
will return the input string.
If nothing is found, the string input is returned.
StringUtils.substringBeforeLast(null, *) = null StringUtils.substringBeforeLast("", *) = "" StringUtils.substringBeforeLast("abcba", "b") = "abc" StringUtils.substringBeforeLast("abc", "c") = "ab" StringUtils.substringBeforeLast("a", "a") = "" StringUtils.substringBeforeLast("a", "z") = "a" StringUtils.substringBeforeLast("a", null) = "a" StringUtils.substringBeforeLast("a", "") = "a"
str
- the String to get a substring from, may be nullseparator
- the String to search for, may be nullnull
if null String inputpublic static String substringAfterLast(String str, String separator)
Gets the substring after the last occurrence of a separator. The separator is not returned.
A null
string input will return null
. An empty ("")
string input will return the empty string. An empty or null
separator
will return the empty string if the input string is not null
.
If nothing is found, the empty string is returned.
StringUtils.substringAfterLast(null, *) = null StringUtils.substringAfterLast("", *) = "" StringUtils.substringAfterLast(*, "") = "" StringUtils.substringAfterLast(*, null) = "" StringUtils.substringAfterLast("abc", "a") = "bc" StringUtils.substringAfterLast("abcba", "b") = "a" StringUtils.substringAfterLast("abc", "c") = "" StringUtils.substringAfterLast("a", "a") = "" StringUtils.substringAfterLast("a", "z") = ""
str
- the String to get a substring from, may be nullseparator
- the String to search for, may be nullnull
if null String inputCopyright © 2016–2018 Spring. All rights reserved.