If you want to program with c or c++, you may want to use use regular
expression library such as GNU rx or lex (lexical analyzer generator).
Another choice is to use Perl. This would be much easier.
If you don't know what regular expression is, please type 'man grep' on
UNIX command line for explanation.