Parses input from a string according to a format