Skip to content
Mohammad Badar Hashimi edited this page Jan 13, 2020 · 1 revision

This library methods used for operations on String type data

Features

  • capitalizeFirstLatter: This method capitalizes the first character of the passed parameter
  • compare: This method compares two input string
  • compareIgnoreCase: This method compares two Strings lexicographically, ignoring case differences
  • contains : This method checks if CharSequence contains a search CharSequence, handling null
  • containsIgnoreCase :This method checks if CharSequence contains a search CharSequence irrespective of case, handling null.
  • containsWithWhiteSpace : This method checks whether the given CharSequence contains any whitespace characters
  • isEmpty : This method checks if a CharSequence is empty ("") or null -isNotEmpty : This method checks if a CharSequence is not empty ("") and not null
  • isBlank: This method checks if a CharSequence is empty (""), null or whitespace only
  • isNotBlank: This method checks if a CharSequence is not empty (""), not null and not whitespace only
  • trim : This method removes control characters (char is less than= 32) from both ends of this String, handling null by returning null
  • trancate : Truncates a String
  • strip: Strips whitespace from the start and end of a String
  • equals : Compares two CharSequences
  • equalsIgnoreCase: Compares two CharSequences ignoring case
  • indexOf : Returns the index within seq of the first occurrence of the specified character
  • lastIndexOf :Returns the index within seq of the last occurrence of the specified character
  • substring: Gets a substring from the specified String avoiding exceptions.
  • removeLeftChar: Gets the leftmost len characters of a String
  • removeRightChar: Gets the rightmost len characters of a String
  • removeMidChar: Gets len characters from the middle of a String
  • substringBefore: Gets the substring before the first occurrence of a separator
  • substringAfter: Gets the substring after the first occurrence of a separator
  • split: Splits the provided text into an array, using whitespace as the separator
  • splitByCharType: Splits a String by Character type
  • join: Joins the elements of the provided array into a single String containing the provided list of elements
  • deletewhiteSpace: Deletes all whitespaces from a String
  • remove: Removes all occurrences of a substring from within the source string
  • removeIgnoreCase: Case insensitive removal of all occurrences of a substring from within the source string
  • removeAll: Removes each substring of the text String that matches the given regular expression
  • replaceOnce: Replaces a String with another String inside a larger String, once
  • replaceIgnoreCase: Case insensitively replaces a String with another String inside a larger String, once
  • replacePattern: Replaces each substring of the source String that matches the given regular expression with the given replacement
  • removePattern: Removes each substring of the source String that matches the given regular expression
  • replaceAll: Replaces each substring of the text String that matches the given regular expression with the given replacement
  • replaceChar: Replaces all occurrences of a character in a String with another
  • overley: Overlays part of a String with another String
  • chomp: Removes one newline from end of a String if it's there, otherwise leave it alone
  • repeat: Repeat a String repeat times to form a new String
  • length: String with repeated character
  • uncapitilize: Uncapitalizes a String, changing the first character to lower case
  • swapCase: Swaps the case of a String changing upper and title case to lower case, and lower case to upper case
  • countMatches: Counts how many times the substring appears in the larger string
  • isAlpha: Checks if the CharSequence contains only Unicode letters
  • isAlphaSpace: Checks if the CharSequence contains only Unicode letters and space (' ')
  • isAlphanumeric: Checks if the CharSequence contains only Unicode letters or digits
  • isAlphanumericSpace: Checks if the CharSequence contains only Unicode letters, digits or space (' ')
  • isNumeric :Checks if the CharSequence contains only Unicode digits. A decimal point is not a Unicode digit and returns false
  • getDigits: Checks if a String sourceString contains Unicode digits, if yes then concatenate all the digits in sourceString and return it as a String
  • isWhiteSpace: Checks if the CharSequence contains only whitespace
  • rotate: Rotate (circular shift) a String of shift characters
  • reverse: Reverses a String
  • reverseDelimited :Reverses a String that is delimited by a specific character
  • abbreviate: Abbreviates a String using ellipses
  • abbreviateMiddle: Abbreviates a String to the length passed, replacing the middle characters with the supplied replacement String
  • difference :Compares two Strings, and returns the portion where they differ
  • startsWith: Check if a CharSequence starts with a specified prefix
  • endswith: Check if a CharSequence ends with a specified suffix
  • normalizeSpace: Returns the argument string with whitespace normalized
  • appendIfMissing: Appends the suffix to the end of the string if the string does not already end with any of the suffixes
  • prependIfMissing: Prepends the prefix to the start of the string if the string does not already start with any of the prefixes
  • wrap: Wraps a string with a char
  • unwrap: Unwraps a given string from anther string
Clone this wiki locally