public String processInstructions(String instructions) {

        /*regex to check if the input is valid.
        to break it down further: ^\d+ \d+\n checks for a number followed by a space and a number, then a line break.
        This is the platform size.
        Then, (\d+ \d+ [NESW] check is the same but followed by one of N E W or S, the initial position.
        The rest \n[LRM]+\n?)+$ checks that the last line is formed from L R and M, for the instructions.
        The command section that is not the platform size can also repeat as many times as necessary. */
        String inputPattern = "^\\d+ \\d+\\n(\\d+ \\d+ [NESW]\\n[LRM]+\\n?)+$";

        //if we don't match the pattern, there could be anything as input, so we stop here.
        if (!instructions.matches(inputPattern)) {
            throw new IllegalArgumentException("Input not recognised as valid!");
        }

        //instructions look good, so get commands and size from the text-based instructions
        ArrayList<RoverCommand> commands = getRoverCommands(instructions);
        String platformSize = getPlatformSize(instructions);
        for (int i = 0; i < commands.size(); i++) { //and add a rover for each command
            rovers.add(new Rover(platformSize, commands.get(i), this));
        }

        String ret = "";

        //then build up the output of each rover's final position
        for (int j = 0; j < rovers.size(); j++) {
            ret += rovers.get(j).getOutput() + "\n";
        }

        //and strip the last line break to conform with the brief
        if (ret.contains("\n")) {
            ret = ret.substring(0, ret.length() - 1);
        }

        return ret;
    }