Class StringRemove

java.lang.Object
com.helger.base.string.StringRemove

@Immutable public final class StringRemove extends Object
Helper class for removing characters or substrings from strings.
Author:
Philip Helger
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable String
    removeAll(@Nullable String sInputString, char cRemoveChar)
    Remove all occurrences of the passed character from the specified input string
    static @Nullable String
    removeAll(@Nullable String sInputString, @Nullable String sRemoveString)
    Remove all occurrences of the passed character from the specified input string
    static @NonNull String
    removeMultiple(@Nullable String sInputString, char @NonNull [] aRemoveChars)
    Optimized remove method that removes a set of characters from an input string!

    Methods inherited from class java.lang.Object

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

    • removeAll

      public static @Nullable String removeAll(@Nullable String sInputString, char cRemoveChar)
      Remove all occurrences of the passed character from the specified input string
      Parameters:
      sInputString - The input string where the character should be removed. If this parameter is null or empty, no removing is done.
      cRemoveChar - The character to be removed.
      Returns:
      The input string as is, if the input string is empty or if the remove char is not contained.
    • removeAll

      public static @Nullable String removeAll(@Nullable String sInputString, @Nullable String sRemoveString)
      Remove all occurrences of the passed character from the specified input string
      Parameters:
      sInputString - The input string where the character should be removed. If this parameter is null or empty, no removing is done.
      sRemoveString - The String to be removed. May be null or empty in which case nothing happens.
      Returns:
      The input string as is, if the input string is empty or if the remove string is empty or not contained.
    • removeMultiple

      public static @NonNull String removeMultiple(@Nullable String sInputString, char @NonNull [] aRemoveChars)
      Optimized remove method that removes a set of characters from an input string!
      Parameters:
      sInputString - The input string.
      aRemoveChars - The characters to remove. May not be null.
      Returns:
      The version of the string without the passed characters or an empty String if the input string was null.