I return the following string from a webpage
Order Number: 1509596 Customer Number: 8
but it coul
if you change orderNumber.replaceAll("[^0-9]", "")
to
orderNumber.replaceAll("[^0-9]", ",")
hence
you will get ,1509596,8
as an answer,
I think this is probably help you to solve ans.
String firstNumber = str.replaceAll("^\\D*(\\d+).*", "$1");
I can't think of a single line that would accomplish this, but the following should work:
String orderString = "Order Number: 1509596 Customer Number: 8";
Pattern p = Pattern.compile("[0-9]+");
Matcher m = p.matcher(orderString);
if (m.find())
{
String orderNr = m.group();
System.out.println(orderNr);
}