Can anyone give me a hand with a touch of regex?
I'm reading in a list of "locations" for a simple text adventure (those so popular back in the day). However, I'm unsure as to how to obtain the input.
The locations all follow the format:
<location_name>, [<item>]
[direction, location_name]
Such as:
Albus Square, Flowers, Traffic Cone
NORTH, Franklandclaw Lecture Theatre
WEST, Library of Enchanted Books
SOUTH, Furnesspuff College
Library of Enchanted Books
EAST, Albus Square
UP, Reading Room
(Subsequent locations are separated by a blank line.)
I'm storing these as Location objects with the structure:
public class Location {
private String name;
private Map<Direction, Location> links;
private List<Item> items;
}
I use a method to retrieve the data from a URL and create the Location objects from the read text, but I'm at a complete block as to do this. I think regex would be of help. Can anyone lend me a well-needed hand?