Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <regex>
- int main() {
- const std::string febDDMM{ "(0[1-9]|[1-2][0-9]).02.(\\d{4}|\\d{2})" };
- const std::string febMMDD{ "02.(0[1-9]|[1-2][0-9]).(\\d{4}|\\d{2})" };
- const std::string DDMM{ "(0[1-9]|[1-2][0-9]|3[0-1]).(01|0[3-9]|1[0-2]).(\\d{4}|\\d{2})" };
- const std::string MMDD{ "(01|0[3-9]|1[0-2]).(0[1-9]|[1-2][0-9]|3[0-1]).(\\d{4}|\\d{2})" };
- const std::string finalExpression{ febDDMM+"|"+febMMDD+"|"+DDMM+"|"+MMDD };
- const std::regex regex(finalExpression);
- std::string inputString{ "startValue" };
- while (std::getline(std::cin, inputString)) {
- std::smatch subMatch;
- while (std::regex_search(inputString, subMatch, regex)) {
- std::cout << subMatch[0] << '\n';
- inputString = subMatch.suffix();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement