216 Kleopatra is visible in the dawn sky, rising at 23:11 (KST) and reaching an altitude of 52° above the south-eastern horizon before fading from view as dawn breaks around 03:51.
from this string i want to get the array of numbers like [216, 23, 11, 52, 3, 51]
how can i get it?
CodePudding user response:
you can use split("\D ") with regex
https://www.onlinegdb.com/FCFoH2gNS
here is the code i made
public class Main
{
public static void main(String[] args) {
System.out.println("Hello, World!");
String text ="216 Kleopatra is visible in the dawn sky, rising at 23:11 (KST) and reaching an altitude of 52 \u00B0 above the south-eastern horizon before fading from view as dawn breaks around 03:51.";
System.out.println(text);
String[] textarr= text.split("\\D ");
for(int i = 0 ; i<textarr.length;i ){
System.out.println(textarr[i] "\n");
}
}
}