Advertisement
Tark_Wight

Untitled

Mar 9th, 2023
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4.  
  5.  
  6. int main() {
  7. const std::string febDDMM{ "(0[1-9]|[1-2][0-9]).02.(\\d{4}|\\d{2})" };
  8. const std::string febMMDD{ "02.(0[1-9]|[1-2][0-9]).(\\d{4}|\\d{2})" };
  9. 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})" };
  10. 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})" };
  11. const std::string finalExpression{ febDDMM+"|"+febMMDD+"|"+DDMM+"|"+MMDD };
  12.  
  13. const std::regex regex(finalExpression);
  14. std::string inputString{ "startValue" };
  15.  
  16. while (std::getline(std::cin, inputString)) {
  17. std::smatch subMatch;
  18. while (std::regex_search(inputString, subMatch, regex)) {
  19. std::cout << subMatch[0] << '\n';
  20. inputString = subMatch.suffix();
  21. }
  22. }
  23.  
  24. return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement