Removing an int from a Line of String. Then, putting the int to a variable

Viewed 151
String team1=z.nextLine(), team2;

int num1, num2;

num1 = z.Int();
team1 = z.nextLine();
team1 = team1.replaceAll("[0-9]","");

System.out.println(team1 + " " + num1);

I need to scan a text file with a content of "Alpha Beta Gamma 52". The String "Alpha Beta Gamma" must be placed to team1 and 52 must be placed to num1. When I use the .replaceAll, it removes the 52 that hinders me to have the integer.

3 Answers
Related