#include <iostream>
#include <regex>
#include <z/core/string.hpp>
int main() {
std::regex regex;
zstring pattern;
while (!std::cin.eof()) {
if (std::cin.eof() && !pattern.
length()) {
break;
}
try {
regex.assign(pattern.
str());
} catch (const std::regex_error &err) {
zstring(err.what()).writeln(std::cout);
continue;
}
zstring(
":").
write(std::cout);
zstring text;
auto match = std::regex_search(text.
str(), regex);
if (std::regex_search(text.
str(), regex)) {
(text + " matches!").writeln(std::cout);
} else {
zstring("does not match.").writeln(std::cout);
}
}
return 0;
}
std::string str() const noexcept
Convert to a std::string.
Definition string.hpp:1623
int length() const noexcept override
Get the character count of the string.
string & readln(std::istream &stream) noexcept
Read string data from a stream until a newline is encountered.
void write(std::ostream &stream) const noexcept
Write string data to a stream in that stream's encoding.
Definition string.hpp:1527