Commons tool set -- stringutils

Source: Internet
Author: User

Stringutils provides the following features and Methods. All methods are null secure and thread secure:

  • Isempty/isblank-Checks if a string contains text
Blank detection. Empty refers to a blank string, that is, the length is 0; Blank refers to a blank string, the length is not necessarily set to 0, may contain blank characters or tabs.
 StringUtils.isEmpty(null)      = true StringUtils.isEmpty("")        = true StringUtils.isEmpty(" ")       = false StringUtils.isEmpty("bob")     = false StringUtils.isEmpty("  bob  ") = false
 StringUtils.isBlank(null)      = true StringUtils.isBlank("")        = true StringUtils.isBlank(" ")       = true StringUtils.isBlank("bob")     = false StringUtils.isBlank("  bob  ") = false
  • Trim/Strip-Removes leading and trailing whitespace
  • Equals-Compares two strings null-safe
  • Startswith-Check if a string starts with a prefix null-safe
  • Endswith-Check if a string ends with a suffix null-safe
  • Indexof/lastindexof/contains-Null-safe index-of checks
  • Indexofany/lastindexofany/indexofanybut/lastindexofanybut-Index-of any of a set of strings
  • Containsonly/containsnone/containsany-Does string contains only/NONE/any of these characters
  • Substring/left/right/Mid-Null-safe substring extractions
  • Substringbefore/substringafter/substringbetween-Substring extraction relative to other strings
  • Split/join-Splits a string into an array of substrings and vice versa
  • Remove/delete-Removes part of a string
  • Replace/overlay-Searches a string and replaces one string with another
  • Chomp/chop-Removes the last part of a string
  • Leftpad/rightpad/center/repeat-Pads a string
  • Uppercase/lowercase/swapcase/capitalize/uncapitalize-Changes the case of a string
  • Countmatches-Counts the number of occurrences of one string in another
  • Isalpha/isnumeric/iswhitespace/isasciiprintable-Checks the characters in a string
  • Defaultstring-Protects against a null input string
  • Reverse/reversedelimited-Reverses a string
  • Abbreviate-Abbreviates a string using ellipsis
  • Difference-Compares strings and reports on their differences
  • Levenshteindistance-The number of changes needed to change one string into another

Word Meaning:

  • Null-null
  • Empty-A zero-length string ("")
  • Space-The space character (' ', Char 32)
  • Whitespace-The characters definedCharacter.isWhitespace(char)
  • Trim-The characters <= 32 as inString.trim()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.