A weird game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
turings-tarpit/regtest.cpp

27 lines
488 B

#include <fmt/core.h>
#include <regex>
#include <string>
using namespace fmt;
using namespace std;
int main(int argc, char *argv[]) {
smatch matches;
regex to_test(argv[1]);
string line(argv[2]);
if(argc != 3) {
println("USAGE: regtest <regex> <line>");
} else {
if(regex_match(line, matches, to_test)) {
println("MATCHED: ");
for(auto &match : matches) {
println("\t{}", match.str());
}
} else {
println("NO MATCH");
}
}
}