i have a large String which includes numbers and text. Now i want exactly a number from that string. The number starts every time with a '6' and three '0' but then the number can be different digits. For example here is a try:
String text1 = "ID 6 IDENTIFICATION NUMBER 600026821 NAME: BECK POSTCODE 60025";
if(text1.contains("6000"))
{
System.out.println(text1.indexOf("6000"));
}
So as you can see the String can also contains postcode digits and ids. But the number i want has always the same length of 9 digits and starts with '6000...'.
So how can i extract that number?
Thanks
EDIT
Ok now i try this one:
String index = "6000";
String text1 = "ID 6 IDENTIFICATION NUMBER 600026821 NAME BECK POSTCODE 60025";
System.out.println(text1.indexOf(index));
String number = text1.substring(text1.indexOf(index), text1.lastIndexOf(text1.indexOf(index) + 5));
System.out.println(number);
It starts but ends not correctly