Commit 2deb5d87fbbeab5c3aa8a75a64a7bbb6e090e209
0 parents
initial commit
Showing
4 changed files
with
45 additions
and
0 deletions
CMakeLists.txt
0 → 100644
src/CMakeLists.txt
0 → 100644
src/cxxopts.hpp
0 → 100644
src/main.cpp
0 → 100644
| 1 | +++ a/src/main.cpp | ||
| 1 | +#include <iostream> | ||
| 2 | + | ||
| 3 | +#include "cxxopts.hpp" | ||
| 4 | + | ||
| 5 | +int main(int argc, char* argv[]) | ||
| 6 | +{ | ||
| 7 | + try | ||
| 8 | + { | ||
| 9 | + | ||
| 10 | + std::basic_regex<char> options("--([a-zA-Z][-a-zA-Z]+)|-([a-zA-Z]+)"); | ||
| 11 | + std::match_results<const char*> result; | ||
| 12 | + | ||
| 13 | + for (int i = 1; i < argc; ++i) | ||
| 14 | + { | ||
| 15 | + std::cout << "Argument " << i << std::endl; | ||
| 16 | + std::regex_match(argv[i], result, options); | ||
| 17 | + std::cout << "empty = " << result.empty() << std::endl; | ||
| 18 | + std::cout << "size = " << result.size() << std::endl; | ||
| 19 | + | ||
| 20 | + std::cout << "matches:" << std::endl; | ||
| 21 | + for (int j = 0; j != result.size(); ++j) | ||
| 22 | + { | ||
| 23 | + std::cout << result[j] << std::endl; | ||
| 24 | + } | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + } catch (const std::regex_error& e) | ||
| 28 | + { | ||
| 29 | + std::cout << "regex_error: " << e.what() << std::endl; | ||
| 30 | + exit(1); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + return 0; | ||
| 34 | +} |