there is alot of ways to accomplish this but you will have to parse everything line by line ether into tokens or the string itself.
Tokens are loads easier and most parsing is done with tokens.
but basicly you will have to read all your lines line by line and have conditions on what types of strings you are looking for. if the string matches your condition delete it or save it.