How can I extract only the numeric values from the input string?
For example, the input string may be like this:
String str=\"abc d 1234567890pqr 548
Just extract the digits
String str=" abc d 1234567890pqr 54897";
for(int i=0; i 47 && str.charAt(i) < 58)
System.out.print(str.charAt(i));
Another version
String str=" abc d 1234567890pqr 54897";
boolean flag = false;
for(int i=0; i 47 && str.charAt(i) < 58) {
System.out.print(str.charAt(i));
flag = true;
} else {
System.out.print( flag ? '\n' : "");
flag = false;
}