StringUtils isAlphanumeric

By | April 14, 2020

StringUtils isAlphanumeric checks if the CharSequence contains only Unicode letters or digits.

  • null will return false.
  • An empty CharSequence (length()=0) will return false.

Examples:
StringUtils.isAlphanumeric (null) = false
StringUtils.isAlphanumeric (“”) = false
StringUtils.isAlphanumeric (” “) = false
StringUtils.isAlphanumeric (“abc”) = true
StringUtils.isAlphanumeric (“ab c”) = false
StringUtils.isAlphanumeric (“ab2c”) = true
StringUtils.isAlphanumeric (“ab-c”) = false

Parameters:

cs the CharSequence to check, may be null

Returns:

true if only contains letters or digits,and is non-null

Since:

3.0 Changed signature from isAlphanumeric(String) to isAlphanumeric(CharSequence)
3.0 Changed “” to return false and not true

 

Recommended Posts:

Get digits from String

Leave a Reply

Your email address will not be published. Required fields are marked *