Extract digits from string | Java
Use a regex such as [^0-9] to remove all non-digits.
From there, just use Integer.parseInt(String);
EX:
String str="sdfvsdf68fsdfsf8999fsdf09";
String numberOnly= str.replaceAll("[^0-9]", "");
Integer numbers = Integer.parseInt(numberOnly);
From there, just use Integer.parseInt(String);
EX:
String str="sdfvsdf68fsdfsf8999fsdf09";
String numberOnly= str.replaceAll("[^0-9]", "");
Integer numbers = Integer.parseInt(numberOnly);
0 comments:
Post a Comment