You don't operate on file data. You get it into memory, either whole or piecemeal, and work with it. My approach would be to read the file line by line, discard the comments, and put the result into a working file or retain it in memory. The approach depends upon your memory resources.

I don't think I'd use regex (I might change my mind after additional thought, but not likely). I'd take the line as a string, locate the ':'s, backtrack to the whitespace, check the enveloped result for a match to the desired labels, and go from there. It's easy enough to do in C, easier in C++.