#include <iostream>
#include <numeric>
#include <regex>
#include <string>
#include <vector>

using namespace std;

int main() {
	const auto first = "Somebody"s;
	const auto second = "words"s;
	const vector<string> words = { "in"s, "lorem"s, "ipsum"s };
	const auto input = "Somebody has typed in some words here."s;
	const regex re("\\b" + first + accumulate(next(cbegin(words)), cend(words), "\\b(?:(\\b" + words.front(), [](const auto& lhs, const auto& rhs) { return lhs + "\\b|\\b" + rhs; }) + "\\b).*|.)*?\\b" + second + "\\b");
	smatch sm;

	if (regex_search(input, sm, re) && sm[1].length() == 0U) {
		cout << "match\n";
	} else {
		cout << "not a match\n";
	}
}