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
Example using java Scanner class
import java.util.Scanner; Scanner s = new Scanner( "abc d 1234567890pqr 54897" ); s.useDelimiter( "\\D+" ); while ( s.hasNextInt() ){ s.nextInt(); // get int }