public static String removeNonDigits(final String str) {
if (str == null || str.length() == 0) {
return "";
}
return str.replaceAll("/[^0-9]/g", "");
}
This should only get the Digits and return but not doing it as expected! Any suggestions?
Java is not Perl :) Try
"[^0-9]+"
This does what you want.
I'd recommend for this particular case just having a small loop over the string.
Use following where
enumValue
is the input string.This will take the string and replace all non-number digits with a "".
eg: input is _126576, the output will be 126576.
Hope this helps.
Try this: