#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;

string string_replace( const string & s, const string & findS, const std::string & replaceS )
{
	string result = s;
	auto pos = s.find( findS );
	if ( pos == string::npos ) {
		return result;
	}
	result.replace( pos, findS.length(), replaceS );
	return string_replace( result, findS, replaceS );
}

string parse(const string& s) {
    static vector< pair< string, string > > patterns = {
        { "\\\\" , "\\" },
    	{ "\\n", "\n" },
    	{ "\\r", "\r" },
    	{ "\\t", "\t" },
    	{ "\\\"", "\"" }
    };
    string result = s;
    for ( const auto & p : patterns ) {
    	result = string_replace( result, p.first, p.second );
    }
    return result;
}

int main() {
    string s1 = R"(hello\n\"this is a string with escape sequences\"\n)";
    string s2 = "hello\n\"this is a string with escape sequences\"\n";
    cout << parse(s1) << endl;
    cout << ( parse(s1) == s2 ) << endl;
}