Class StringUtils

java.lang.Object
uk.blankaspect.common.string.StringUtils

public class StringUtils extends Object
This class contains utility methods that relate to strings and character sequences.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    This is an enumeration of the ways in which an input string may be split by the split*(…) methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The prefix that is recognised by the escape(CharSequence, String) method.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    applyPrefix(String str, String prefix)
    Returns a string that is derived from the specified string by applying the specified prefix in a way that depends on whether or not the prefix ends with an underscore ('_', U+005F): If the prefix ends with an underscore, the returned string consists of the prefix followed by the input string.
    static boolean
    Returns true if the specified collection of strings contains the specified target string, ignoring letter case when comparing strings.
    static String
    escape(CharSequence seq, String metachars)
    Returns a string that consists of the specified character sequence with each occurrence of any of the specified set of metacharacters immediately preceded by a backslash ('\', U+005C).
    static List<String>
    Splits the specified text at line separators and returns the resulting list of lines.
    static String
    Returns a string that is derived from the specified string by converting its first character to lower case.
    static String
    Returns a string that is derived from the specified string by converting its first character to upper case.
    static int
    Returns the maximum length of the specified character sequences.
    static int
    Returns the maximum length of the specified character sequences.
    static String
    getPrefixFirst(String str, char ch)
    Returns the substring of the specified string from the start of the string to (but not including) the first occurrence of the specified character.
    static String
    getPrefixLast(String str, char ch)
    Returns the substring of the specified string from the start of the string to (but not including) the last occurrence of the specified character.
    static String
    getSuffixAfterFirst(String str, char ch)
    Returns the substring of the specified string from (but not including) the first occurrence of the specified character to the end of the string.
    static String
    getSuffixAfterLast(String str, char ch)
    Returns the substring of the specified string from (but not including) the last occurrence of the specified character to the end of the string.
    static String
    getSuffixFirst(String str, char ch)
    Returns the substring of the specified string from (and including) the first occurrence of the specified character to the end of the string.
    static String
    getSuffixLast(String str, char ch)
    Returns the substring of the specified string from (and including) the last occurrence of the specified character to the end of the string.
    static int
    Returns the index of the first occurrence of the specified target string in the specified collection of strings, ignoring letter case when comparing strings.
    static boolean
    Returns true if the specified string is null or empty or it contains only whitespace characters.
    static boolean
    Returns true if the specified string is null or empty.
    static String
    join(char separator, boolean includeTrailingSeparator, CharSequence... seqs)
    Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences and an optional separator after the last character sequence.
    static String
    join(char separator, boolean includeTrailingSeparator, Iterable<? extends CharSequence> seqs)
    Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences and an optional separator after the last character sequence.
    static String
    join(char separator, CharSequence... seqs)
    Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences.
    static String
    join(char separator, Iterable<? extends CharSequence> seqs)
    Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences.
    static String
    join(CharSequence separator, boolean includeTrailingSeparator, CharSequence... seqs)
    Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences and an optional separator after the last character sequence.
    static String
    join(CharSequence separator, boolean includeTrailingSeparator, Iterable<? extends CharSequence> seqs)
    Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences and an optional separator after the last character sequence.
    static String
    join(CharSequence separator, CharSequence... seqs)
    Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences.
    static String
    join(CharSequence separator, Iterable<? extends CharSequence> seqs)
    Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences.
    static String
    padAfter(CharSequence seq, int length)
    Returns the specified character sequence as a string that is padded with trailing spaces (U+0020), if necessary, so that the string has the specified length.
    static String
    padAfter(CharSequence seq, int length, char ch)
    Returns the specified character sequence as a string that is padded at the end with repetitions of the specified character, if necessary, so that the string has the specified length.
    static String
    padBefore(CharSequence seq, int length)
    Returns the specified character sequence as a string that is padded with leading spaces (U+0020), if necessary, so that the string has the specified length.
    static String
    padBefore(CharSequence seq, int length, char ch)
    Returns the specified character sequence as a string that is padded at the start with repetitions of the specified character, if necessary, so that the string has the specified length.
    static String
    removePrefix(String str, String prefix)
    Removes the specified prefix (ie, leading substring) from the specified string, if the string starts with the prefix, and returns the resulting string.
    static String
    removeSuffix(String str, String suffix)
    Removes the specified suffix (ie, trailing substring) from the specified string, if the string ends with the suffix, and returns the resulting string.
    static List<String>
    split(String str, char separator)
    Returns a list of the substrings of the specified string that result from splitting the input string at each occurrence of the specified separator character and removing the separators.
    static List<String>
    split(String str, char separator, boolean discardFinalEmptyElement)
    Returns a list of the substrings of the specified string that result from splitting the input string at each occurrence of the specified separator character and removing the separators.
    static String[]
    splitAt(String str, int index, StringUtils.SplitMode splitMode)
    Returns the two substrings that result from splitting the specified string at the specified index.
    static String[]
    splitAtFirst(String str, char ch)
    Returns the two substrings that result from splitting the specified string at the first occurrence of the specified character, which is discarded.
    static String[]
    splitAtFirst(String str, char ch, StringUtils.SplitMode splitMode)
    Returns the two substrings that result from splitting the specified string at the first occurrence of the specified character, which may optionally be
    static String[]
    splitAtLast(String str, char ch)
    Returns the two substrings that result from splitting the specified string at the last occurrence of the specified character, which is discarded.
    static String[]
    splitAtLast(String str, char ch, StringUtils.SplitMode splitMode)
    Returns the two substrings that result from splitting the specified string at the last occurrence of the specified character, which may optionally be
    static String
    Converts the specified text to camel case and returns the resulting string.
    static String
    wrap(CharSequence seq, int maxLineLength)
    Returns the string that results from splitting the specified character sequence into substrings at word breaks that maximise the length of each substring (with the word break removed) while not exceeding the specified maximum length, then joining adjacent substrings with a line feed (U+000A).
    static List<String>
    wrapLines(CharSequence seq, int maxLineLength)
    Returns the list of strings that results from splitting the specified character sequence into substrings at word breaks that maximise the length of each substring (with the word break removed) while not exceeding the specified maximum length.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • isNullOrEmpty

      public static boolean isNullOrEmpty(String str)
      Returns true if the specified string is null or empty.
      Parameters:
      str - the string that will be tested.
      Returns:
      true if str is null or empty.
    • isNullOrBlank

      public static boolean isNullOrBlank(String str)
      Returns true if the specified string is null or empty or it contains only whitespace characters.
      Parameters:
      str - the string that will be tested.
      Returns:
      true if str is null or empty or it contains only whitespace characters.
    • getMaxLength

      public static int getMaxLength(Iterable<? extends CharSequence> seqs)
      Returns the maximum length of the specified character sequences.
      Parameters:
      seqs - the character sequences whose maximum length is desired.
      Returns:
      the maximum length of seqs.
    • getMaxLength

      public static int getMaxLength(CharSequence... seqs)
      Returns the maximum length of the specified character sequences.
      Parameters:
      seqs - the character sequences whose maximum length is desired.
      Returns:
      the maximum length of seqs.
    • padBefore

      public static String padBefore(CharSequence seq, int length)
      Returns the specified character sequence as a string that is padded with leading spaces (U+0020), if necessary, so that the string has the specified length. If the length of the input sequence is greater than or equal to the specified length, the input sequence is returned as a string with no additional padding.
      Parameters:
      seq - the input sequence of characters.
      length - the desired length of the padded output string.
      Returns:
      seq as a string, padded with leading spaces, if necessary, so that the length of the returned string is length.
    • padBefore

      public static String padBefore(CharSequence seq, int length, char ch)
      Returns the specified character sequence as a string that is padded at the start with repetitions of the specified character, if necessary, so that the string has the specified length. If the length of the input sequence is greater than or equal to the specified length, the input sequence is returned as a string with no additional padding.
      Parameters:
      seq - the input sequence of characters.
      length - the desired length of the padded output string.
      ch - the character with which the string will be padded.
      Returns:
      seq as a string, padded at the start with repetitions of ch, if necessary, so that the length of the returned string is length.
    • padAfter

      public static String padAfter(CharSequence seq, int length)
      Returns the specified character sequence as a string that is padded with trailing spaces (U+0020), if necessary, so that the string has the specified length. If the length of the input sequence is greater than or equal to the specified length, the input sequence is returned as a string with no additional padding.
      Parameters:
      seq - the input sequence of characters.
      length - the desired length of the padded output string.
      Returns:
      seq as a string, padded with trailing spaces, if necessary, so that the length of the returned string is length.
    • padAfter

      public static String padAfter(CharSequence seq, int length, char ch)
      Returns the specified character sequence as a string that is padded at the end with repetitions of the specified character, if necessary, so that the string has the specified length. If the length of the input sequence is greater than or equal to the specified length, the input sequence is returned as a string with no additional padding.
      Parameters:
      seq - the input sequence of characters.
      length - the desired length of the padded output string.
      ch - the character with which the string will be padded.
      Returns:
      seq as a string, padded at the end with repetitions of ch, if necessary, so that the length of the returned string is length.
    • split

      public static List<String> split(String str, char separator)
      Returns a list of the substrings of the specified string that result from splitting the input string at each occurrence of the specified separator character and removing the separators.
      Parameters:
      str - the string that is to be split.
      separator - the separator character.
      Returns:
      a list of the substrings of str that result from splitting the input string at each occurrence of separator.
    • split

      public static List<String> split(String str, char separator, boolean discardFinalEmptyElement)
      Returns a list of the substrings of the specified string that result from splitting the input string at each occurrence of the specified separator character and removing the separators. The last element of the list of substrings may optionally be discarded if it is the empty string.
      Parameters:
      str - the string that is to be split.
      separator - the separator character.
      discardFinalEmptyElement - if true, the last element of the list of substrings will be discarded if it is the empty string.
      Returns:
      a list of the substrings of str that result from splitting the input string at each occurrence of separator and optionally discarding the last element if it is empty.
    • splitAt

      public static String[] splitAt(String str, int index, StringUtils.SplitMode splitMode)

      Returns the two substrings that result from splitting the specified string at the specified index. The character at the specified index in the input string may optionally be

      • included in the first substring (the prefix),
      • included in the second substring (the suffix) or
      • discarded,

      according to the specified split mode.

      Parameters:
      str - the string that is to be split.
      index - the index of the character at which str is to be split. If it is less than 0, the result is as described below.
      splitMode - the way in which the character of str at index will be treated.
      Returns:
      an array containing the two substrings that result from splitting str at index, taking into account splitMode. If index is less than 0, the two returned values will be
      • str and null, if splitMode is NONE, or
      • str and the empty string, if splitMode is PREFIX or SUFFIX.
    • splitAtFirst

      public static String[] splitAtFirst(String str, char ch)
      Returns the two substrings that result from splitting the specified string at the first occurrence of the specified character, which is discarded.
      Parameters:
      str - the string that is to be split.
      ch - the character at which str is to be split.
      Returns:
      an array containing the two substrings that result from splitting str at the first occurrence of ch. If str does not contain ch, the two returned values will be str and null.
    • splitAtFirst

      public static String[] splitAtFirst(String str, char ch, StringUtils.SplitMode splitMode)

      Returns the two substrings that result from splitting the specified string at the first occurrence of the specified character, which may optionally be

      • included in the first substring (the prefix),
      • included in the second substring (the suffix) or
      • discarded,

      according to the specified split mode.

      Parameters:
      str - the string that is to be split.
      ch - the character at which str is to be split.
      splitMode - the way in which the first occurrence of ch will be treated.
      Returns:
      an array containing the two substrings that result from splitting str at the first occurrence of ch. If str does not contain ch, the two returned values will be
      • str and null, if splitMode is NONE, or
      • str and the empty string, if splitMode is PREFIX or SUFFIX.
    • splitAtLast

      public static String[] splitAtLast(String str, char ch)
      Returns the two substrings that result from splitting the specified string at the last occurrence of the specified character, which is discarded.
      Parameters:
      str - the string that is to be split.
      ch - the character at which str is to be split.
      Returns:
      an array containing the two substrings that result from splitting str at the last occurrence of ch. If str does not contain ch, the two returned values will be str and null.
    • splitAtLast

      public static String[] splitAtLast(String str, char ch, StringUtils.SplitMode splitMode)

      Returns the two substrings that result from splitting the specified string at the last occurrence of the specified character, which may optionally be

      • included in the first substring (the prefix),
      • included in the second substring (the suffix) or
      • discarded,

      according to the specified split mode.

      Parameters:
      str - the string that is to be split.
      ch - the character at which str is to be split.
      splitMode - the way in which the last occurrence of ch will be treated.
      Returns:
      an array containing the two substrings that result from splitting str at the last occurrence of ch. If str does not contain ch, the two returned values will be
      • str and null, if splitMode is NONE, or
      • str and the empty string, if splitMode is PREFIX or SUFFIX.
    • getPrefixFirst

      public static String getPrefixFirst(String str, char ch)
      Returns the substring of the specified string from the start of the string to (but not including) the first occurrence of the specified character.
      Parameters:
      str - the string from which a leading substring is to be extracted.
      ch - the character whose first occurrence denotes the exclusive end of the prefix.
      Returns:
      the substring of str from the start of the string to (but not including) the first occurrence of ch. If str does not contain ch, str is returned.
    • getPrefixLast

      public static String getPrefixLast(String str, char ch)
      Returns the substring of the specified string from the start of the string to (but not including) the last occurrence of the specified character.
      Parameters:
      str - the string from which a leading substring is to be extracted.
      ch - the character whose last occurrence denotes the exclusive end of the prefix.
      Returns:
      the substring of str from the start of the string to (but not including) the last occurrence of ch. If str does not contain ch, str is returned.
    • getSuffixFirst

      public static String getSuffixFirst(String str, char ch)
      Returns the substring of the specified string from (and including) the first occurrence of the specified character to the end of the string.
      Parameters:
      str - the string from which a trailing substring is to be extracted.
      ch - the character whose first occurrence denotes the inclusive start of the suffix.
      Returns:
      the substring of str from (and including) the first occurrence of ch to the end of the string. If str does not contain ch, str is returned.
    • getSuffixAfterFirst

      public static String getSuffixAfterFirst(String str, char ch)
      Returns the substring of the specified string from (but not including) the first occurrence of the specified character to the end of the string.
      Parameters:
      str - the string from which a trailing substring is to be extracted.
      ch - the character whose first occurrence denotes the exclusive start of the suffix.
      Returns:
      the substring of str from (but not including) the first occurrence of ch to the end of the string. If str does not contain ch, str is returned.
    • getSuffixLast

      public static String getSuffixLast(String str, char ch)
      Returns the substring of the specified string from (and including) the last occurrence of the specified character to the end of the string.
      Parameters:
      str - the string from which a trailing substring is to be extracted.
      ch - the character whose last occurrence denotes the inclusive start of the suffix.
      Returns:
      the substring of str from (and including) the last occurrence of ch to the end of the string. If str does not contain ch, str is returned.
    • getSuffixAfterLast

      public static String getSuffixAfterLast(String str, char ch)
      Returns the substring of the specified string from (but not including) the last occurrence of the specified character to the end of the string.
      Parameters:
      str - the string from which a trailing substring is to be extracted.
      ch - the character whose last occurrence denotes the exclusive start of the suffix.
      Returns:
      the substring of str from (but not including) the last occurrence of ch to the end of the string. If str does not contain ch, str is returned.
    • removePrefix

      public static String removePrefix(String str, String prefix)
      Removes the specified prefix (ie, leading substring) from the specified string, if the string starts with the prefix, and returns the resulting string.
      Parameters:
      str - the string from which to remove prefix.
      prefix - the leading substring that is to be removed from str.
      Returns:
      str without prefix, if str starts with prefix; otherwise, str.
    • removeSuffix

      public static String removeSuffix(String str, String suffix)
      Removes the specified suffix (ie, trailing substring) from the specified string, if the string ends with the suffix, and returns the resulting string.
      Parameters:
      str - the string from which to remove suffix.
      suffix - the trailing substring that is to be removed from str.
      Returns:
      str without suffix, if str ends with suffix; otherwise, str.
    • join

      public static String join(char separator, CharSequence... seqs)
      Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences.
      Parameters:
      separator - the character that will separate adjacent elements of seqs in the output string.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements.
    • join

      public static String join(char separator, Iterable<? extends CharSequence> seqs)
      Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences.
      Parameters:
      separator - the character that will separate adjacent elements of seqs in the output string.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements.
    • join

      public static String join(CharSequence separator, CharSequence... seqs)
      Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences.
      Parameters:
      separator - the character sequence that will separate adjacent elements of seqs in the output string. If it is null, the elements of seqs will be concatenated without a separator.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements.
    • join

      public static String join(CharSequence separator, Iterable<? extends CharSequence> seqs)
      Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences.
      Parameters:
      separator - the character sequence that will separate adjacent elements of seqs in the output string. If it is null, the elements of seqs will be concatenated without a separator.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements.
    • join

      public static String join(char separator, boolean includeTrailingSeparator, CharSequence... seqs)
      Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences and an optional separator after the last character sequence.
      Parameters:
      separator - the character that will separate adjacent elements of seqs in the output string.
      includeTrailingSeparator - if true, a separator will be appended to the last element of seqs.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements and an optional separator after the last element.
    • join

      public static String join(char separator, boolean includeTrailingSeparator, Iterable<? extends CharSequence> seqs)
      Returns a string that consists of the specified character sequences in order, with the specified separator between adjacent character sequences and an optional separator after the last character sequence.
      Parameters:
      separator - the character that will separate adjacent elements of seqs in the output string.
      includeTrailingSeparator - if true, a separator will be appended to the last element of seqs.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements and an optional separator after the last element.
    • join

      public static String join(CharSequence separator, boolean includeTrailingSeparator, CharSequence... seqs)
      Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences and an optional separator after the last character sequence.
      Parameters:
      separator - the character sequence that will separate adjacent elements of seqs in the output string. If it is null, the elements of seqs will be concatenated without a separator.
      includeTrailingSeparator - if true, a separator will be appended to the last element of seqs.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements and an optional separator after the last element.
    • join

      public static String join(CharSequence separator, boolean includeTrailingSeparator, Iterable<? extends CharSequence> seqs)
      Returns a string that consists of the specified character sequences in order, with the specified optional separator between adjacent character sequences and an optional separator after the last character sequence.
      Parameters:
      separator - the character sequence that will separate adjacent elements of seqs in the output string. If it is null, the elements of seqs will be concatenated without a separator.
      includeTrailingSeparator - if true, a separator will be appended to the last element of seqs.
      seqs - the character sequences to be joined together.
      Returns:
      a string that consists of the elements of seqs, with separator between adjacent elements and an optional separator after the last element.
    • extractLines

      public static List<String> extractLines(CharSequence text)
      Splits the specified text at line separators and returns the resulting list of lines. The line separators that are recognised are CR+LF (U+000D, U+000A) and LF (U+000A). The line separators are not included in the output list.
      Parameters:
      text - the text that will be split into lines at line separators.
      Returns:
      a list of the strings that result from splitting text at line separators.
    • wrap

      public static String wrap(CharSequence seq, int maxLineLength)
      Returns the string that results from splitting the specified character sequence into substrings at word breaks that maximise the length of each substring (with the word break removed) while not exceeding the specified maximum length, then joining adjacent substrings with a line feed (U+000A). A word break is a sequence of one or more space characters (U+0020).

      The length of a substring may exceed the specified limit if the substring does not contain a space character.

      Parameters:
      seq - the character sequence that is to be split into substrings at appropriate word breaks.
      maxLineLength - the maximum length of a substring when splitting the input sequence.
      Returns:
      the string that results from splitting seq into substrings at word breaks that maximise the length of each substring while not exceeding maxLineLength, then joining adjacent substrings with a line feed (U+000A).
    • wrapLines

      public static List<String> wrapLines(CharSequence seq, int maxLineLength)
      Returns the list of strings that results from splitting the specified character sequence into substrings at word breaks that maximise the length of each substring (with the word break removed) while not exceeding the specified maximum length. A word break is a sequence of one or more space characters (U+0020).

      The length of a substring may exceed the specified limit if the substring does not contain a space character.

      Parameters:
      seq - the character sequence that is to be split into substrings at appropriate word breaks.
      maxLineLength - the maximum length of a substring when splitting the input sequence.
      Returns:
      the list of strings that results from splitting seq into substrings at word breaks that maximise the length of each substring while not exceeding maxLineLength.
    • firstCharToLowerCase

      public static String firstCharToLowerCase(String str)
      Returns a string that is derived from the specified string by converting its first character to lower case.
      Parameters:
      str - the string to be converted.
      Returns:
      str with its first character converted to lower case.
      Throws:
      NullPointerException - if str is null.
      IndexOutOfBoundsException - if str is empty.
    • firstCharToUpperCase

      public static String firstCharToUpperCase(String str)
      Returns a string that is derived from the specified string by converting its first character to upper case.
      Parameters:
      str - the string to be converted.
      Returns:
      str with its first character converted to upper case.
      Throws:
      NullPointerException - if str is null.
      IndexOutOfBoundsException - if str is empty.
    • toCamelCase

      public static String toCamelCase(CharSequence text)
      Converts the specified text to camel case and returns the resulting string.

      The conversion is described below. In the description,

      1. Each letter that immediately follows a digit or a non-alphanumeric character is converted to upper case except for a letter that follows a sequence of a letter and an apostrophe (U+0027).
      2. All other letters are converted to lower case.
      3. All non-alphanumeric characters are removed.
      Parameters:
      text - the text that is to be converted.
      Returns:
      the camel-case string that results from the conversion of text.
    • applyPrefix

      public static String applyPrefix(String str, String prefix)
      Returns a string that is derived from the specified string by applying the specified prefix in a way that depends on whether or not the prefix ends with an underscore ('_', U+005F):
      • If the prefix ends with an underscore, the returned string consists of the prefix followed by the input string.
      • If the prefix does not end with an underscore, the returned string consists of the prefix followed by the input string with its first character converted to upper case.
      Parameters:
      str - the string to which prefix will be applied.
      prefix - the prefix that will be applied to str.
      Returns:
      the result of applying prefix to str in the way described above.
    • escape

      public static String escape(CharSequence seq, String metachars)
      Returns a string that consists of the specified character sequence with each occurrence of any of the specified set of metacharacters immediately preceded by a backslash ('\', U+005C).
      Example:
      If the input sequence is "${name}" and the metacharacters are "${}", the returned value is "\$\{name\}".
      Parameters:
      seq - the string to be processed.
      metachars - a string containing the metacharacters that will be preceded by a backslash in the output string.
      Returns:
      a string consisting of seq with each occurrence of any of metachars preceded by a backslash.
    • containsIgnoreCase

      public static boolean containsIgnoreCase(String target, Iterable<String> strs)
      Returns true if the specified collection of strings contains the specified target string, ignoring letter case when comparing strings.
      Parameters:
      target - the target string.
      strs - the strings that will be searched for target.
      Returns:
      true if strs contains target, ignoring letter case.
    • indexOfIgnoreCase

      public static int indexOfIgnoreCase(String target, Iterable<String> strs)
      Returns the index of the first occurrence of the specified target string in the specified collection of strings, ignoring letter case when comparing strings.
      Parameters:
      target - the target string.
      strs - the strings that will be searched for target.
      Returns:
      the index of the first occurrence of target in strs, or -1 if strs does not contain target.