Im working on a project that can measure the distance between two cities. I am trying to set it so that the user will input a one line command to search for two cities, for example "distance Dallas New York City". Now I have it so that the line is split into an array of strings using the .split() method, however it splits on white space and punctuation, meaning that cities with names longer than one word won't work. Ideally I would like it to work so that typing "distance Dallas "New York City"" but I am not sure how to do this.
public static void main(String[] args) {
CSVReader reader = new CSVReader();
Scanner in = new Scanner(System.in);
LinkedList[] entries = new LinkedList[14089];
boolean running = true;
reader.run("cities.csv", entries);
while(running){
String[] arg = in.nextLine().split("[,;:\\.\\s]+");
if(arg[0].equals("retrieve")){
search(arg[1], entries);
System.out.println();
}
if(arg[0].equals("distance")){
distance(arg[1], arg[2], entries);
System.out.println();
}
if(arg[0].equals("stop")){
stop(entries);
running = false;
}
}
}
}