#include <string>
#include <iostream>
#include <regex>
using namespace std;

int main() {
    std::regex re(R"((?:^|[^\\])(?:\\{2})*'([^'\\]*(?:\\[\s\S][^'\\]*)*)')");
	std::string s("server ('m1.labs.teradata.com') username ('u\\'se)r_*5') password('uer 5') dbname ('default')");
	unsigned count = 0;
	for(std::sregex_iterator i = std::sregex_iterator(s.begin(), s.end(), re);
                             i != std::sregex_iterator();
                             ++i)
    {
        std::smatch m = *i;
        cout << "the token is"<<"   "<< m.str(1) << endl;
        count++;
    }
	cout << "There were " << count << " tokens found." << endl;
	return 0;
}