I tried to find the answer to my problem in the questions history but they just come back in more than one thousand and after scanning through a few tens of matching answers
public static String splitting(String str, int num){
String arr[] = str.split("[^0-9]");
for(String s:arr)
if(s.length() == num)
return s;
return null;
}
test with
public static void main(String[] args) {
String s = "Some text 987654321 and some more text 123456 and some other text again 654321 and more text in the end";
System.out.println(splitting(s, 6));
}
output is
123456