public class StringUtil
extends java.lang.Object
Format
.Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
capitalize(java.lang.String str)
Capitalizes a string, changing the first letter to
upper case.
|
static java.lang.String |
compressChars(java.lang.String s,
char c)
Compress multiple occurrences of given char into one appearance.
|
static boolean |
containsOnlyDigits(java.lang.CharSequence string)
Returns
true if string contains only digits. |
static boolean |
containsOnlyDigitsAndSigns(java.lang.CharSequence string)
Returns
true if string contains only digits
or signs plus or minus. |
static boolean |
containsOnlyWhitespaces(java.lang.CharSequence string)
Returns
true if string contains only white spaces. |
static java.lang.String |
convertCharset(java.lang.String source,
java.lang.String srcCharsetName,
java.lang.String newCharsetName)
Converts string charset.
|
static int |
count(java.lang.String source,
char c) |
static int |
count(java.lang.String source,
char c,
int start) |
static int |
count(java.lang.String source,
java.lang.String sub)
Counts substring occurrences in a source string.
|
static int |
count(java.lang.String source,
java.lang.String sub,
int start) |
static int |
countIgnoreCase(java.lang.String source,
java.lang.String sub)
Count substring occurrences in a source string, ignoring case.
|
static java.lang.String |
crop(java.lang.String string)
Crops string by setting empty strings to
null . |
static void |
cropAll(java.lang.String... strings)
Crops all elements of string array.
|
static java.lang.String |
cutBetween(java.lang.String string,
java.lang.String left,
java.lang.String right)
Cuts a string between two other strings.
|
static java.lang.String |
cutFromIndexOf(java.lang.String string,
char c)
Cuts the string from the first index of provided char to the end.
|
static java.lang.String |
cutFromIndexOf(java.lang.String string,
java.lang.String substring)
Cuts the string from the first index of provided substring to the end.
|
static java.lang.String |
cutPrefix(java.lang.String string,
java.lang.String prefix)
Cuts prefix if exists.
|
static java.lang.String |
cutSuffix(java.lang.String string,
java.lang.String suffix)
Cuts sufix if exists.
|
static java.lang.String |
cutSurrounding(java.lang.String string,
java.lang.String fix) |
static java.lang.String |
cutSurrounding(java.lang.String string,
java.lang.String prefix,
java.lang.String suffix)
Removes surrounding prefix and suffixes.
|
static java.lang.String |
cutToIndexOf(java.lang.String string,
char c)
Cuts the string from beginning to the first index of provided char.
|
static java.lang.String |
cutToIndexOf(java.lang.String string,
java.lang.String substring)
Cuts the string from beginning to the first index of provided substring.
|
static java.lang.String |
decapitalize(java.lang.String name)
Utility method to take a string and convert it to normal Java variable
name capitalization.
|
static char |
detectQuoteChar(java.lang.String str)
Detects quote character or return 0.
|
static boolean |
endsWithChar(java.lang.String s,
char c)
Returns if string ends with provided character.
|
static boolean |
endsWithIgnoreCase(java.lang.String src,
java.lang.String subS)
Tests if this string ends with the specified suffix.
|
static int |
endsWithOne(java.lang.String src,
java.lang.String... dest)
Checks if string ends with at least one string from the provided array.
|
static int |
endsWithOneIgnoreCase(java.lang.String src,
java.lang.String... dest)
Checks if string ends with at least one string from the provided array.
|
static boolean |
equals(java.lang.String[] as,
java.lang.String[] as1)
Compares two string arrays.
|
static boolean |
equals(java.lang.String s1,
java.lang.String s2)
Compares 2 strings.
|
static boolean |
equalsIgnoreCase(java.lang.String[] as,
java.lang.String[] as1)
Compares two string arrays.
|
static int |
equalsOne(java.lang.String src,
java.lang.String... dest)
Compares string with at least one from the provided array.
|
static int |
equalsOneIgnoreCase(java.lang.String src,
java.lang.String... dest)
Compares string with at least one from the provided array, ignoring case.
|
static java.lang.String |
findCommonPrefix(java.lang.String... strings)
Finds common prefix for several strings.
|
static byte[] |
getBytes(java.lang.String string)
Returns String bytes using Jodds default encoding.
|
static byte[] |
getBytes(java.lang.String string,
java.lang.String charsetName) |
static java.lang.String |
ifNotNull(java.lang.String input,
java.util.function.Function<java.lang.String,java.lang.String> stringFunction)
Executes function on a string if not
null . |
static int |
indexOf(java.lang.String src,
char c,
int startIndex,
int endIndex)
Finds the first occurrence of a character in the given source but within limited range (start, end].
|
static int[] |
indexOf(java.lang.String s,
java.lang.String... arr)
Finds the very first index of a substring from the specified array.
|
static int[] |
indexOf(java.lang.String s,
java.lang.String[] arr,
int offset)
Finds the very first index of a substring from the specified array.
|
static int |
indexOf(java.lang.String src,
java.lang.String sub,
int startIndex,
int endIndex)
Finds first occurrence of a substring in the given source but within limited range [start, end).
|
static int |
indexOfChars(java.lang.String string,
char[] chars) |
static int |
indexOfChars(java.lang.String string,
char[] chars,
int startindex)
Returns the very first index of any char from provided string, starting from specified index offset.
|
static int |
indexOfChars(java.lang.String string,
java.lang.String chars) |
static int |
indexOfChars(java.lang.String string,
java.lang.String chars,
int startindex)
Returns the very first index of any char from provided string, starting from specified index offset.
|
static int |
indexOfIgnoreCase(java.lang.String src,
char c,
int startIndex,
int endIndex)
Finds the first occurrence of a character in the given source but within limited range (start, end].
|
static int[] |
indexOfIgnoreCase(java.lang.String s,
java.lang.String... arr)
Finds the very first index of a substring from the specified array.
|
static int |
indexOfIgnoreCase(java.lang.String src,
java.lang.String subS)
Finds first index of a substring in the given source string with ignored case.
|
static int[] |
indexOfIgnoreCase(java.lang.String s,
java.lang.String[] arr,
int start)
Finds the very first index of a substring from the specified array.
|
static int |
indexOfIgnoreCase(java.lang.String src,
java.lang.String subS,
int startIndex)
Finds first index of a substring in the given source string with ignored
case.
|
static int |
indexOfIgnoreCase(java.lang.String src,
java.lang.String sub,
int startIndex,
int endIndex)
Finds first index of a substring in the given source string and range with
ignored case.
|
static int |
indexOfNonWhitespace(java.lang.String string) |
static int |
indexOfNonWhitespace(java.lang.String string,
int startindex) |
static int |
indexOfNonWhitespace(java.lang.String string,
int startindex,
int endindex) |
static int[] |
indexOfRegion(java.lang.String string,
java.lang.String leftBoundary,
java.lang.String rightBoundary) |
static int[] |
indexOfRegion(java.lang.String string,
java.lang.String leftBoundary,
java.lang.String rightBoundary,
char escape) |
static int[] |
indexOfRegion(java.lang.String string,
java.lang.String leftBoundary,
java.lang.String rightBoundary,
char escape,
int offset)
Returns indexes of the first string region.
|
static int[] |
indexOfRegion(java.lang.String string,
java.lang.String leftBoundary,
java.lang.String rightBoundary,
int offset)
Returns indexes of the first region without escaping character.
|
static int |
indexOfUnescapedChar(java.lang.String src,
char sub,
char escapeChar) |
static int |
indexOfUnescapedChar(java.lang.String src,
char sub,
char escapeChar,
int startIndex) |
static int |
indexOfWhitespace(java.lang.String string)
Returns first index of a whitespace character.
|
static int |
indexOfWhitespace(java.lang.String string,
int startindex) |
static int |
indexOfWhitespace(java.lang.String string,
int startindex,
int endindex)
Returns first index of a whitespace character, starting from specified index offset.
|
static java.lang.String |
insert(java.lang.String src,
java.lang.String insert) |
static java.lang.String |
insert(java.lang.String src,
java.lang.String insert,
int offset)
Inserts a string on provided offset.
|
static boolean |
isAllBlank(java.lang.String... strings)
Determines if string array contains just blank strings.
|
static boolean |
isAllEmpty(java.lang.String... strings)
Determines if string array contains empty strings.
|
static boolean |
isBlank(java.lang.CharSequence string)
Determines if a string is blank (
null or containsOnlyWhitespaces(CharSequence) ). |
static boolean |
isCharAtEqual(java.lang.String string,
int index,
char charToCompare)
Safely compares provided char with char on given location.
|
static boolean |
isCharAtEscaped(java.lang.String src,
int ndx,
char escapeChar)
Returns
true if character at provided index position is escaped
by escape character. |
static boolean |
isEmpty(java.lang.CharSequence string)
Determines if a string is empty (
null or zero-length). |
static boolean |
isNotBlank(java.lang.CharSequence string)
Determines if string is not blank.
|
static boolean |
isNotEmpty(java.lang.CharSequence string)
Determines if a string is not empty.
|
static boolean |
isSubstringAt(java.lang.String string,
java.lang.String substring,
int offset)
Returns
true if substring exist at given offset in a string. |
static java.lang.String |
join(java.util.Collection collection,
char separator)
Joins an collection of objects into one string with separator.
|
static java.lang.String |
join(java.util.Collection collection,
java.lang.String separator) |
static java.lang.String |
join(java.lang.Object[] array)
Joins an array of objects into one string without separators.
|
static java.lang.String |
join(java.lang.Object[] array,
char separator)
Joins an array of objects into one string with separator.
|
static java.lang.String |
join(java.lang.Object[] array,
java.lang.String separator)
Joins an array of objects into one string with separator.
|
static int |
lastIndexOf(java.lang.String src,
char c,
int startIndex,
int endIndex)
Finds last index of a character in the given source string in specified range [end, start]
|
static int[] |
lastIndexOf(java.lang.String s,
java.lang.String... arr)
Finds the very last index of a substring from the specified array.
|
static int[] |
lastIndexOf(java.lang.String s,
java.lang.String[] arr,
int fromIndex)
Finds the very last index of a substring from the specified array.
|
static int |
lastIndexOf(java.lang.String src,
java.lang.String sub,
int startIndex,
int endIndex)
Finds last index of a substring in the given source string in specified range [end, start]
See
indexOf(String, String, int, int) for details about the speed. |
static int |
lastIndexOfIgnoreCase(java.lang.String src,
char c,
int startIndex,
int endIndex)
Finds last index of a character in the given source string in specified range [end, start]
|
static int[] |
lastIndexOfIgnoreCase(java.lang.String s,
java.lang.String... arr)
Finds the very last index of a substring from the specified array.
|
static int |
lastIndexOfIgnoreCase(java.lang.String s,
java.lang.String subS)
Finds last index of a substring in the given source string with ignored
case.
|
static int[] |
lastIndexOfIgnoreCase(java.lang.String s,
java.lang.String[] arr,
int fromIndex)
Finds the very last index of a substring from the specified array.
|
static int |
lastIndexOfIgnoreCase(java.lang.String src,
java.lang.String subS,
int startIndex)
Finds last index of a substring in the given source string with ignored
case.
|
static int |
lastIndexOfIgnoreCase(java.lang.String src,
java.lang.String sub,
int startIndex,
int endIndex)
Finds last index of a substring in the given source string with ignored
case in specified range.
|
static int |
lastIndexOfNonWhitespace(java.lang.String src) |
static int |
lastIndexOfNonWhitespace(java.lang.String src,
int startIndex) |
static int |
lastIndexOfNonWhitespace(java.lang.String src,
int startIndex,
int endIndex) |
static int |
lastIndexOfWhitespace(java.lang.String src) |
static int |
lastIndexOfWhitespace(java.lang.String src,
int startIndex)
Returns last index of a whitespace.
|
static int |
lastIndexOfWhitespace(java.lang.String src,
int startIndex,
int endIndex)
Returns last index of a whitespace.
|
static java.lang.String |
maxCommonPrefix(java.lang.String one,
java.lang.String two)
Returns max common prefix of two strings.
|
static java.lang.String |
newString(byte[] bytes) |
static java.lang.String |
newString(byte[] bytes,
java.lang.String charsetName) |
static java.lang.String |
prefix(java.lang.String string,
java.lang.String prefix)
Inserts prefix if doesn't exist.
|
static java.lang.String |
remove(java.lang.String string,
char ch)
Removes a single character from string.
|
static java.lang.String |
remove(java.lang.String s,
java.lang.String sub)
Removes all substring occurrences from the string.
|
static java.lang.String |
removeChars(java.lang.String src,
char... chars)
Removes set of characters from string.
|
static java.lang.String |
removeChars(java.lang.String src,
java.lang.String chars)
Removes all characters contained in provided string.
|
static java.lang.String |
removeQuotes(java.lang.String string)
Removes starting and ending single or double quotes.
|
static java.lang.String |
repeat(char c,
int count) |
static java.lang.String |
repeat(java.lang.String source,
int count)
Creates a new string that contains the provided string a number of times.
|
static java.lang.String |
replace(java.lang.String s,
java.lang.String[] sub,
java.lang.String[] with)
Replaces many substring at once.
|
static java.lang.String |
replace(java.lang.String s,
java.lang.String sub,
java.lang.String with)
Replaces all occurrences of a certain pattern in a string with a
replacement string.
|
static java.lang.String |
replaceChar(java.lang.String s,
char sub,
char with)
Replaces all occurrences of a character in a string.
|
static java.lang.String |
replaceChars(java.lang.String s,
char[] sub,
char[] with)
Replaces all occurrences of a characters in a string.
|
static java.lang.String |
replaceFirst(java.lang.String s,
char sub,
char with)
Replaces the very first occurrence of a character in a string.
|
static java.lang.String |
replaceFirst(java.lang.String s,
java.lang.String sub,
java.lang.String with)
Replaces the very first occurrence of a substring with supplied string.
|
static java.lang.String |
replaceIgnoreCase(java.lang.String s,
java.lang.String[] sub,
java.lang.String[] with)
Replaces many substring at once.
|
static java.lang.String |
replaceLast(java.lang.String s,
char sub,
char with)
Replaces the very last occurrence of a character in a string.
|
static java.lang.String |
replaceLast(java.lang.String s,
java.lang.String sub,
java.lang.String with)
Replaces the very last occurrence of a substring with supplied string.
|
static java.lang.String |
reverse(java.lang.String s)
Reverse a string.
|
static java.lang.String |
shorten(java.lang.String s,
int length,
java.lang.String suffix)
Shorten string to given length.
|
static java.lang.String[] |
split(java.lang.String src,
java.lang.String delimiter)
Splits a string in several parts (tokens) that are separated by delimiter.
|
static java.lang.String[] |
splitc(java.lang.String src,
char delimiter)
Splits a string in several parts (tokens) that are separated by single delimiter
characters.
|
static java.lang.String[] |
splitc(java.lang.String src,
char[] delimiters)
Splits a string in several parts (tokens) that are separated by delimiter
characters.
|
static java.lang.String[] |
splitc(java.lang.String src,
java.lang.String d)
Splits a string in several parts (tokens) that are separated by delimiter
characters.
|
static boolean |
startsWithChar(java.lang.String s,
char c)
Returns if string starts with given character.
|
static boolean |
startsWithIgnoreCase(java.lang.String src,
java.lang.String subS)
Tests if this string starts with the specified prefix with ignored case.
|
static boolean |
startsWithIgnoreCase(java.lang.String src,
java.lang.String subS,
int startIndex)
Tests if this string starts with the specified prefix with ignored case
and with the specified prefix beginning a specified index.
|
static int |
startsWithOne(java.lang.String src,
java.lang.String... dest)
Checks if string starts with at least one string from the provided array.
|
static int |
startsWithOneIgnoreCase(java.lang.String src,
java.lang.String... dest)
Checks if string starts with at least one string from the provided array.
|
static java.lang.String |
stripChar(java.lang.String string,
char c)
Strips leading and trailing char from given string.
|
static java.lang.String |
stripFromChar(java.lang.String string,
char c)
Strips everything from the first appearance of given char.
|
static java.lang.String |
stripLeadingChar(java.lang.String string,
char c)
Strips leading char if string starts with one.
|
static java.lang.String |
stripToChar(java.lang.String string,
char c)
Strips everything up to the first appearance of given char.
|
static java.lang.String |
stripTrailingChar(java.lang.String string,
char c)
Strips trailing char if string ends with one.
|
static java.lang.String |
substring(java.lang.String string,
int fromIndex,
int toIndex)
Returns a new string that is a substring of this string.
|
static java.lang.String |
suffix(java.lang.String string,
java.lang.String suffix)
Appends suffix if doesn't exist.
|
static java.lang.String |
surround(java.lang.String string,
java.lang.String fix) |
static java.lang.String |
surround(java.lang.String string,
java.lang.String prefix,
java.lang.String suffix)
Surrounds the string with provided prefix and suffix if such missing from string.
|
static java.lang.String |
title(java.lang.String string)
Makes a title-cased string from given input.
|
static java.lang.String |
toHexString(byte[] bytes)
Converts bytes to hex string.
|
static java.lang.String |
toLowerCase(java.lang.String s)
Converts all of the characters in the string to lower case, based on the
portal instance's default locale.
|
static java.lang.String |
toLowerCase(java.lang.String s,
java.util.Locale locale)
Converts all of the characters in the string to lower case, based on the
locale.
|
static java.lang.String |
toSafeString(java.lang.Object value)
Converts safely an object to a string.
|
static java.lang.String |
toString(java.lang.Object value)
Converts safely an object to a string.
|
static java.lang.String[] |
toStringArray(java.lang.Object value)
Converts an array object to array of strings, where every element
of input array is converted to a string.
|
static java.lang.String |
toUpperCase(java.lang.String s)
Converts all of the characters in the string to upper case, based on the
portal instance's default locale.
|
static java.lang.String |
toUpperCase(java.lang.String s,
java.util.Locale locale)
Converts all of the characters in the string to upper case, based on the
locale.
|
static void |
trimAll(java.lang.String... strings)
Trims array of strings.
|
static java.lang.String |
trimDown(java.lang.String string)
Trims string and sets to
null if trimmed string is empty. |
static void |
trimDownAll(java.lang.String... strings)
Trims array of strings where empty strings are set to
null . |
static java.lang.String |
trimLeft(java.lang.String src)
Trim whitespaces from the left.
|
static java.lang.String |
trimRight(java.lang.String src)
Trim whitespaces from the right.
|
static java.lang.String |
truncate(java.lang.String string,
int length)
Sets the maximum length of the string.
|
static java.lang.String |
uncapitalize(java.lang.String str)
Uncapitalizes a
String , changing the first letter to
lower case. |
public static java.lang.String replace(java.lang.String s, java.lang.String sub, java.lang.String with)
s
- string to be inspectedsub
- string pattern to be replacedwith
- string that should go where the pattern waspublic static java.lang.String replaceChar(java.lang.String s, char sub, char with)
s
- input stringsub
- character to replacewith
- character to replace withpublic static java.lang.String replaceChars(java.lang.String s, char[] sub, char[] with)
s
- input stringsub
- characters to replacewith
- characters to replace withpublic static java.lang.String replaceFirst(java.lang.String s, java.lang.String sub, java.lang.String with)
s
- source stringsub
- substring to replacewith
- substring to replace withpublic static java.lang.String replaceFirst(java.lang.String s, char sub, char with)
s
- stringsub
- char to replacewith
- char to replace withpublic static java.lang.String replaceLast(java.lang.String s, java.lang.String sub, java.lang.String with)
s
- source stringsub
- substring to replacewith
- substring to replace withpublic static java.lang.String replaceLast(java.lang.String s, char sub, char with)
s
- stringsub
- char to replacewith
- char to replace withpublic static java.lang.String remove(java.lang.String s, java.lang.String sub)
s
- source stringsub
- substring to removepublic static java.lang.String removeChars(java.lang.String src, java.lang.String chars)
src
- source stringchars
- string containing characters to removepublic static java.lang.String removeChars(java.lang.String src, char... chars)
src
- stringchars
- characters to removepublic static java.lang.String remove(java.lang.String string, char ch)
string
- source stringch
- character to removepublic static boolean equals(java.lang.String s1, java.lang.String s2)
null
, false
is returned. if
both string are null
, true
is returned.s1
- first string to compares2
- second stringtrue
if strings are equal, otherwise false
public static boolean isEmpty(java.lang.CharSequence string)
null
or zero-length).public static boolean isAllEmpty(java.lang.String... strings)
isEmpty(CharSequence)
public static boolean isBlank(java.lang.CharSequence string)
null
or containsOnlyWhitespaces(CharSequence)
).public static boolean isNotBlank(java.lang.CharSequence string)
public static boolean isAllBlank(java.lang.String... strings)
public static boolean containsOnlyWhitespaces(java.lang.CharSequence string)
true
if string contains only white spaces.public static boolean containsOnlyDigits(java.lang.CharSequence string)
true
if string contains only digits.public static boolean containsOnlyDigitsAndSigns(java.lang.CharSequence string)
true
if string contains only digits
or signs plus or minus.public static boolean isNotEmpty(java.lang.CharSequence string)
public static java.lang.String toString(java.lang.Object value)
public static java.lang.String toSafeString(java.lang.Object value)
null
an empty
string is returned.public static java.lang.String[] toStringArray(java.lang.Object value)
public static java.lang.String capitalize(java.lang.String str)
str
- string to capitalize, may be nulluncapitalize(String)
public static java.lang.String uncapitalize(java.lang.String str)
String
, changing the first letter to
lower case. No other letters are changed.str
- the String to uncapitalize, may be nullnull
if nullcapitalize(String)
public static java.lang.String decapitalize(java.lang.String name)
Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".
name
- The string to be decapitalized.public static java.lang.String title(java.lang.String string)
public static java.lang.String truncate(java.lang.String string, int length)
public static java.lang.String substring(java.lang.String string, int fromIndex, int toIndex)
fromIndex
and extends to the character
at index toIndex - 1
. However, index values can be negative,
and then the real index will be calculated from the strings end. This
allows to specify, e.g. substring(1,-1)
to cut one character
from both ends of the string. If fromIndex
is negative
and toIndex
is 0, it will return last characters of the string.
Also, this method will never throw an exception if index is out of range.public static boolean isSubstringAt(java.lang.String string, java.lang.String substring, int offset)
true
if substring exist at given offset in a string.public static java.lang.String[] split(java.lang.String src, java.lang.String delimiter)
Method is much, much faster then regexp String.split()
,
and a bit faster then StringTokenizer
.
src
- string to splitdelimiter
- split delimiterpublic static java.lang.String[] splitc(java.lang.String src, java.lang.String d)
src
- source to examined
- string with delimiter characterspublic static java.lang.String[] splitc(java.lang.String src, char[] delimiters)
src
- source to examinedelimiters
- char array with delimiter characterspublic static java.lang.String[] splitc(java.lang.String src, char delimiter)
src
- source to examinedelimiter
- delimiter characterpublic static java.lang.String compressChars(java.lang.String s, char c)
public static int indexOf(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
String.indexOf(String, int)
is much faster (since it uses char[] value directly) and should be used when no range is needed.src
- source string for examinationsub
- substring to findstartIndex
- starting indexendIndex
- ending indexpublic static int indexOf(java.lang.String src, char c, int startIndex, int endIndex)
public static int indexOfIgnoreCase(java.lang.String src, char c, int startIndex, int endIndex)
public static int indexOfIgnoreCase(java.lang.String src, java.lang.String subS)
src
- source string for examinationsubS
- substring to findindexOfIgnoreCase(String, String, int)
public static int indexOfIgnoreCase(java.lang.String src, java.lang.String subS, int startIndex)
src
- source string for examinationsubS
- substring to findstartIndex
- starting index from where search beginspublic static int indexOfIgnoreCase(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
src
- source string for examinationsub
- substring to findstartIndex
- starting index from where search beginsendIndex
- endint indexindexOfIgnoreCase(String, String, int)
public static int lastIndexOfIgnoreCase(java.lang.String s, java.lang.String subS)
s
- source stringsubS
- substring to findindexOfIgnoreCase(String, String, int)
,
lastIndexOfIgnoreCase(String, String, int)
public static int lastIndexOfIgnoreCase(java.lang.String src, java.lang.String subS, int startIndex)
src
- source string for examinationsubS
- substring to findstartIndex
- starting index from where search beginsindexOfIgnoreCase(String, String, int)
public static int lastIndexOfIgnoreCase(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
src
- source to examinesub
- substring to findstartIndex
- starting indexendIndex
- end indexpublic static int lastIndexOf(java.lang.String src, java.lang.String sub, int startIndex, int endIndex)
indexOf(String, String, int, int)
for details about the speed.src
- source to examinesub
- substring to findstartIndex
- starting indexendIndex
- end indexpublic static int lastIndexOf(java.lang.String src, char c, int startIndex, int endIndex)
public static int lastIndexOfIgnoreCase(java.lang.String src, char c, int startIndex, int endIndex)
public static int lastIndexOfWhitespace(java.lang.String src)
public static int lastIndexOfWhitespace(java.lang.String src, int startIndex)
public static int lastIndexOfWhitespace(java.lang.String src, int startIndex, int endIndex)
public static int lastIndexOfNonWhitespace(java.lang.String src)
public static int lastIndexOfNonWhitespace(java.lang.String src, int startIndex)
public static int lastIndexOfNonWhitespace(java.lang.String src, int startIndex, int endIndex)
public static boolean startsWithIgnoreCase(java.lang.String src, java.lang.String subS)
src
- source string to testsubS
- starting substringtrue
if the character sequence represented by the argument is
a prefix of the character sequence represented by this string;
false
otherwise.public static boolean startsWithIgnoreCase(java.lang.String src, java.lang.String subS, int startIndex)
src
- source string to testsubS
- starting substringstartIndex
- index from where to testtrue
if the character sequence represented by the argument is
a prefix of the character sequence represented by this string;
false
otherwise.public static boolean endsWithIgnoreCase(java.lang.String src, java.lang.String subS)
src
- String to testsubS
- suffixtrue
if the character sequence represented by the argument is
a suffix of the character sequence represented by this object;
false
otherwise.public static boolean startsWithChar(java.lang.String s, char c)
public static boolean endsWithChar(java.lang.String s, char c)
public static int count(java.lang.String source, java.lang.String sub)
source
- source stringsub
- substring to countpublic static int count(java.lang.String source, java.lang.String sub, int start)
public static int count(java.lang.String source, char c)
public static int count(java.lang.String source, char c, int start)
public static int countIgnoreCase(java.lang.String source, java.lang.String sub)
source
- source stringsub
- substring to countpublic static int[] indexOf(java.lang.String s, java.lang.String... arr)
null
if
noting found.s
- source stringarr
- string arraypublic static int[] indexOf(java.lang.String s, java.lang.String[] arr, int offset)
null
if noting found.s
- source stringarr
- string arrayoffset
- starting positionpublic static int[] indexOfIgnoreCase(java.lang.String s, java.lang.String... arr)
null
if noting found.s
- source stringarr
- string arraypublic static int[] indexOfIgnoreCase(java.lang.String s, java.lang.String[] arr, int start)
null
if noting found.s
- source stringarr
- string arraystart
- starting positionpublic static int[] lastIndexOf(java.lang.String s, java.lang.String... arr)
null
if noting found.s
- source stringarr
- string arraypublic static int[] lastIndexOf(java.lang.String s, java.lang.String[] arr, int fromIndex)
null
if noting found.s
- source stringarr
- string arrayfromIndex
- starting positionpublic static int[] lastIndexOfIgnoreCase(java.lang.String s, java.lang.String... arr)
null
if noting found.s
- source stringarr
- string arraypublic static int[] lastIndexOfIgnoreCase(java.lang.String s, java.lang.String[] arr, int fromIndex)
null
if noting found.s
- source stringarr
- string arrayfromIndex
- starting positionpublic static boolean equals(java.lang.String[] as, java.lang.String[] as1)
as
- first string arrayas1
- second string arraytrue
if all array elements matchespublic static boolean equalsIgnoreCase(java.lang.String[] as, java.lang.String[] as1)
as
- first string arrayas1
- second string arraypublic static java.lang.String replace(java.lang.String s, java.lang.String[] sub, java.lang.String[] with)
s
- source stringsub
- substrings arraywith
- replace with arraypublic static java.lang.String replaceIgnoreCase(java.lang.String s, java.lang.String[] sub, java.lang.String[] with)
s
- source stringsub
- substrings arraywith
- replace with arraypublic static int equalsOne(java.lang.String src, java.lang.String... dest)
-1
is returned.public static int equalsOneIgnoreCase(java.lang.String src, java.lang.String... dest)
-1
is returned.public static int startsWithOne(java.lang.String src, java.lang.String... dest)
-1
is returned.public static int startsWithOneIgnoreCase(java.lang.String src, java.lang.String... dest)
-1
is returned.public static int endsWithOne(java.lang.String src, java.lang.String... dest)
-1
is returned.public static int endsWithOneIgnoreCase(java.lang.String src, java.lang.String... dest)
-1
is returned.public static int indexOfChars(java.lang.String string, java.lang.String chars)
indexOfChars(String, String, int)
public static int indexOfChars(java.lang.String string, java.lang.String chars, int startindex)
-1
if nothing found.public static int indexOfChars(java.lang.String string, char[] chars)
public static int indexOfChars(java.lang.String string, char[] chars, int startindex)
-1
if nothing found.public static int indexOfWhitespace(java.lang.String string)
public static int indexOfWhitespace(java.lang.String string, int startindex)
public static int indexOfWhitespace(java.lang.String string, int startindex, int endindex)
public static int indexOfNonWhitespace(java.lang.String string)
public static int indexOfNonWhitespace(java.lang.String string, int startindex)
public static int indexOfNonWhitespace(java.lang.String string, int startindex, int endindex)
public static java.lang.String stripLeadingChar(java.lang.String string, char c)
public static java.lang.String stripTrailingChar(java.lang.String string, char c)
public static java.lang.String stripChar(java.lang.String string, char c)
public static java.lang.String stripToChar(java.lang.String string, char c)
public static java.lang.String stripFromChar(java.lang.String string, char c)
public static void trimAll(java.lang.String... strings)
null
array elements are ignored.public static void trimDownAll(java.lang.String... strings)
null
.
null
elements of the array are ignored.trimDown(String)
public static java.lang.String trimDown(java.lang.String string)
null
if trimmed string is empty.public static java.lang.String crop(java.lang.String string)
null
.public static void cropAll(java.lang.String... strings)
public static java.lang.String trimLeft(java.lang.String src)
public static java.lang.String trimRight(java.lang.String src)
public static int[] indexOfRegion(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary)
public static int[] indexOfRegion(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary, int offset)
public static int[] indexOfRegion(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary, char escape)
public static int[] indexOfRegion(java.lang.String string, java.lang.String leftBoundary, java.lang.String rightBoundary, char escape, int offset)
Escape character may be used to prefix boundaries so they can be ignored.
Double escaped region will be found, and first index of the result will be
decreased to include one escape character.
If region is not founded, null
is returned.
public static java.lang.String join(java.lang.Object[] array)
public static java.lang.String join(java.lang.Object[] array, char separator)
public static java.lang.String join(java.util.Collection collection, char separator)
public static java.lang.String join(java.util.Collection collection, java.lang.String separator)
public static java.lang.String join(java.lang.Object[] array, java.lang.String separator)
public static java.lang.String convertCharset(java.lang.String source, java.lang.String srcCharsetName, java.lang.String newCharsetName)
public static boolean isCharAtEqual(java.lang.String string, int index, char charToCompare)
public static java.lang.String surround(java.lang.String string, java.lang.String fix)
surround(String, String, String)
public static java.lang.String surround(java.lang.String string, java.lang.String prefix, java.lang.String suffix)
public static java.lang.String prefix(java.lang.String string, java.lang.String prefix)
public static java.lang.String suffix(java.lang.String string, java.lang.String suffix)
public static java.lang.String cutToIndexOf(java.lang.String string, java.lang.String substring)
public static java.lang.String cutToIndexOf(java.lang.String string, char c)
public static java.lang.String cutFromIndexOf(java.lang.String string, java.lang.String substring)
public static java.lang.String cutFromIndexOf(java.lang.String string, char c)
public static java.lang.String cutPrefix(java.lang.String string, java.lang.String prefix)
public static java.lang.String cutSuffix(java.lang.String string, java.lang.String suffix)
public static java.lang.String cutSurrounding(java.lang.String string, java.lang.String fix)
cutSurrounding(String, String, String)
public static java.lang.String cutSurrounding(java.lang.String string, java.lang.String prefix, java.lang.String suffix)
public static java.lang.String cutBetween(java.lang.String string, java.lang.String left, java.lang.String right)
null
is returned.
If indexes of left or right strings are wrong, empty string is returned.public static boolean isCharAtEscaped(java.lang.String src, int ndx, char escapeChar)
true
if character at provided index position is escaped
by escape character.public static int indexOfUnescapedChar(java.lang.String src, char sub, char escapeChar)
public static int indexOfUnescapedChar(java.lang.String src, char sub, char escapeChar, int startIndex)
public static java.lang.String insert(java.lang.String src, java.lang.String insert)
public static java.lang.String insert(java.lang.String src, java.lang.String insert, int offset)
public static java.lang.String repeat(java.lang.String source, int count)
public static java.lang.String repeat(char c, int count)
public static java.lang.String reverse(java.lang.String s)
public static java.lang.String maxCommonPrefix(java.lang.String one, java.lang.String two)
public static java.lang.String findCommonPrefix(java.lang.String... strings)
public static java.lang.String shorten(java.lang.String s, int length, java.lang.String suffix)
public static java.lang.String toLowerCase(java.lang.String s)
s
- the string to convertnull
if the
string is null
public static java.lang.String toLowerCase(java.lang.String s, java.util.Locale locale)
String.toLowerCase
.s
- the string to convertlocale
- apply this locale's rules, if null
default locale is usednull
if the
string is null
public static java.lang.String toUpperCase(java.lang.String s)
s
- the string to convertnull
if the
string is null
public static java.lang.String toUpperCase(java.lang.String s, java.util.Locale locale)
s
- the string to convertlocale
- apply this locale's rulesnull
if the
string is null
public static java.lang.String removeQuotes(java.lang.String string)
public static java.lang.String toHexString(byte[] bytes)
public static java.lang.String ifNotNull(java.lang.String input, java.util.function.Function<java.lang.String,java.lang.String> stringFunction)
null
. Otherwise returns an empty string.public static byte[] getBytes(java.lang.String string)
public static byte[] getBytes(java.lang.String string, java.lang.String charsetName)
public static java.lang.String newString(byte[] bytes)
public static java.lang.String newString(byte[] bytes, java.lang.String charsetName)
public static char detectQuoteChar(java.lang.String str)
Copyright © 2003-present Jodd Team