Last active
April 11, 2018 06:40
-
-
Save Cvetomird91/066734aa72688daac8fb16ed905edef3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string> | |
| #include <iostream> | |
| #include <boost/regex.hpp> | |
| #include <boost/date_time/gregorian/gregorian.hpp> | |
| int main(int argc, char** argv) { | |
| boost::regex date(R"((\d{2})\.(\d{2})\.(\d{4}))"); | |
| boost::smatch match; | |
| boost::gregorian::date d; | |
| std::ostringstream ss; | |
| std::string filename(" of 18.05.2017.txt"); | |
| if (boost::regex_search(filename, match, date)) { | |
| std::cout << match[0] << std::endl; | |
| std::cout << match[1] << std::endl; | |
| std::cout << match[2] << std::endl; | |
| std::cout << match[3] << std::endl; | |
| d = boost::gregorian::date(std::stoi(match[3]), std::stoi(match[2]), std::stoi(match[1])); | |
| ss << d.day() << ' ' << d.month().as_number() << ' ' << d.year() << '\n'; | |
| std::cout << ss.str(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment