@Test public void removeAllCharsExceptDigits() throws Exception { Assert.assertEquals(null, StringUtil.removeAllCharsExceptDigits(null)); Assert.assertEquals("", StringUtil.removeAllCharsExceptDigits("")); Assert.assertEquals("", StringUtil.removeAllCharsExceptDigits("ABC")); Assert.assertEquals("1", StringUtil.removeAllCharsExceptDigits("+1")); Assert.assertEquals("13135551212", StringUtil.removeAllCharsExceptDigits("+1 313-555 1212")); }
static public String removeAllCharsExceptDigits(String str0) { if (str0 == null) { return null; } if (str0.length() == 0) { return str0; } StringBuilder buf = new StringBuilder(str0.length()); int length = str0.length(); for (int i = 0; i < length; i++) { char c = str0.charAt(i); if (Character.isDigit(c)) { buf.append(c); } } return buf.toString(); }
StringUtil { static public String removeAllCharsExceptDigits(String str0) { if (str0 == null) { return null; } if (str0.length() == 0) { return str0; } StringBuilder buf = new StringBuilder(str0.length()); int length = str0.length(); for (int i = 0; i < length; i++) { char c = str0.charAt(i); if (Character.isDigit(c)) { buf.append(c); } } return buf.toString(); } }
StringUtil { static public String removeAllCharsExceptDigits(String str0) { if (str0 == null) { return null; } if (str0.length() == 0) { return str0; } StringBuilder buf = new StringBuilder(str0.length()); int length = str0.length(); for (int i = 0; i < length; i++) { char c = str0.charAt(i); if (Character.isDigit(c)) { buf.append(c); } } return buf.toString(); }  }
StringUtil { static public String removeAllCharsExceptDigits(String str0) { if (str0 == null) { return null; } if (str0.length() == 0) { return str0; } StringBuilder buf = new StringBuilder(str0.length()); int length = str0.length(); for (int i = 0; i < length; i++) { char c = str0.charAt(i); if (Character.isDigit(c)) { buf.append(c); } } return buf.toString(); }  static String substituteWithEnvironment(String string0); static String substituteWithProperties(String string0, String startStr, String endStr, Properties properties); static boolean isSafeString(String string0); static boolean isSafeChar(char ch); static String capitalize(String string0); static String uncapitalize(String string0); static boolean contains(String[] strings, String targetString); static int indexOf(String[] strings, String targetString); static String stripQuotes(String string0); static boolean containsOnlyDigits(String string0); static String[] split(String str, char delim); final static String formatForPrint(String input); static String[] toStringArray(Object[] objArray); static byte[] getAsciiBytes(String input); static String getAsciiString(byte[] input); static String trimTrailing(String str); static String truncate(String value, int length); static String slice(String value,
            int beginOffset, int endOffset,
            boolean trim); @Deprecated static String toHexString(byte[] bytes); @Deprecated static String toHexString(byte[] bytes, int offset, int length); @Deprecated static byte[] toHexByte(String hexString, int offset, int length); @Deprecated static byte[] fromHexString(String hexString); @Deprecated static byte[] fromHexString(String hexString, int offset, int length); static boolean isPrintableChar(char ch); static String hexDump(String prefix, byte[] data); static String SQLToUpperCase(String s); static boolean SQLEqualsIgnoreCase(String s1, String s2); static String normalizeSQLIdentifier(String id); static String compressQuotes(String source, String quotes); static String quoteStringLiteral(String string); static String stringify(int[] raw); static boolean isEmpty(String string0); static boolean isEqual(String string0, String string1); static String toStringWithNullAsEmpty(Object obj); static String toStringWithNullAsReplaced(Object obj); static String toStringWithNullAsNull(Object obj); static boolean isEqual(String string0, String string1, boolean caseSensitive); static String readToString(InputStream in); static String escapeXml(String value); static String removeAllCharsExceptDigits(String str0); }
StringUtil { static public String removeAllCharsExceptDigits(String str0) { if (str0 == null) { return null; } if (str0.length() == 0) { return str0; } StringBuilder buf = new StringBuilder(str0.length()); int length = str0.length(); for (int i = 0; i < length; i++) { char c = str0.charAt(i); if (Character.isDigit(c)) { buf.append(c); } } return buf.toString(); }  static String substituteWithEnvironment(String string0); static String substituteWithProperties(String string0, String startStr, String endStr, Properties properties); static boolean isSafeString(String string0); static boolean isSafeChar(char ch); static String capitalize(String string0); static String uncapitalize(String string0); static boolean contains(String[] strings, String targetString); static int indexOf(String[] strings, String targetString); static String stripQuotes(String string0); static boolean containsOnlyDigits(String string0); static String[] split(String str, char delim); final static String formatForPrint(String input); static String[] toStringArray(Object[] objArray); static byte[] getAsciiBytes(String input); static String getAsciiString(byte[] input); static String trimTrailing(String str); static String truncate(String value, int length); static String slice(String value,
            int beginOffset, int endOffset,
            boolean trim); @Deprecated static String toHexString(byte[] bytes); @Deprecated static String toHexString(byte[] bytes, int offset, int length); @Deprecated static byte[] toHexByte(String hexString, int offset, int length); @Deprecated static byte[] fromHexString(String hexString); @Deprecated static byte[] fromHexString(String hexString, int offset, int length); static boolean isPrintableChar(char ch); static String hexDump(String prefix, byte[] data); static String SQLToUpperCase(String s); static boolean SQLEqualsIgnoreCase(String s1, String s2); static String normalizeSQLIdentifier(String id); static String compressQuotes(String source, String quotes); static String quoteStringLiteral(String string); static String stringify(int[] raw); static boolean isEmpty(String string0); static boolean isEqual(String string0, String string1); static String toStringWithNullAsEmpty(Object obj); static String toStringWithNullAsReplaced(Object obj); static String toStringWithNullAsNull(Object obj); static boolean isEqual(String string0, String string1, boolean caseSensitive); static String readToString(InputStream in); static String escapeXml(String value); static String removeAllCharsExceptDigits(String str0); static char[] HEX_TABLE; }