StringUtils getDigits method

By | April 13, 2020

StringUtils getDigits method checks if a String str contains Unicode digits, if yes then concatenate all the digits in str and return it as a String.

An empty (“”) String will be returned if no digits found in str.

Examples:
StringUtils.getDigits (null) = null
StringUtils.getDigits (“”) = “”
StringUtils.getDigits (“abc”) = “”
StringUtils.getDigits (“1000$”) = “1000”
StringUtils.getDigits (“1123~45”) = “112345”
StringUtils.getDigits (“(541) 754-3456”) = “5417543456”
StringUtils.getDigits (“\u0345\u0968\u0944”) = “\u0345\u0968\u0944”

Parameters:
str the String to extract digits from, may be null

Returns:
String with only digits,or an empty (“”) String if no digits found, or null String if str is null

Since:
3.6

 

Recommended Posts:

StringUtils equalsAny() method

Leave a Reply

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