Hello,
I need to get an integer from my string.
I know it is possible with regex, etc but the problem is that I want to have the second integer instead of the first one:
Example with the following string:
will give me 1, but i need 23.
This is the java code I use in my library:
but any other solution is welcome.
Thanks for any help
Tomas
I need to get an integer from my string.
I know it is possible with regex, etc but the problem is that I want to have the second integer instead of the first one:
Example with the following string:
Apples 1 (23 apples)
will give me 1, but i need 23.
This is the java code I use in my library:
B4X:
**
* Finds an integer in a string.
* @param findInt
* @return
*/
public String findIntegerInString(String findInt) {
Pattern intsOnly = Pattern.compile("\\d+");
Matcher makeMatch = intsOnly.matcher(findInt);
makeMatch.find();
String inputInt = makeMatch.group();
return inputInt;
}
but any other solution is welcome.
Thanks for any help
Tomas