#include <iostream>
#include <regex>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string input("tag = value\ntag2 = value2\nvalue continuation2\n# comment for tag3\ntag3 = value3");

	const regex re("(?:\\s*#.*\\n)*(\\w+)\\s*=\\s*((?:[^#=\\n]+(\\n|$))+)");

	for (sregex_iterator i(input.cbegin(), input.cend(), re); i != sregex_iterator(); ++i) {
		const string tag = i->operator[](1);
		const string value = i->operator[](2);

		cout << tag << ':' << value << endl;
	}
}