Bet you didn't do a search on the word "parsing" here on this forum...

See Code Examples... Communications Example : PC to PIC bi-directional dialogue. Example reads in a serial string (byte at a time) and acts on it...