Regular expressions (AKA regexes) are a great way for a program to parse strings. Here’s how to use one: You simply create a sort of “template” for how the string should look.
An earlier post I made here links to a PDF file that goes over how to use a regex, and here is a link to an excellent explanation of how regular expressions work internally.