Let's say there are three strings:
String s1 = "6A";
String s2 = "14T";
String s3 = "S32";
I need to extract numeric values (i.e. 6,14 and 32) and characters (A,T and S).
If the first character was always a digit, then this code would work:
int num = Integer.parseInt(s1.substring(0,1));
However, this is not applicable to s2
and s3
.