Member 15942356 wrote:
but I can't help feeling that there is a better way
Probably there is a better way unless you really only want the key and will not want anything else. If you are going to want something else (or several things) then the better way is to write (or find) and actual parser. So code, not just regex, which parses files based on the structure specified from the spec.