I have a String and I want to extract the (only) sequence of digits in the string.
Example: helloThisIsA1234Sample. I want the 1234
It\'s a given that the s
You can also use java.util.Scanner:
java.util.Scanner
new Scanner(str).useDelimiter("[^\\d]+").nextInt()
You can use next() instead of nextInt() to get the digits as string.
next()
nextInt()
You can check for the presence of number using hasNextInt() on the Scanner.
hasNextInt()
Scanner