Commit de73da53b512cda43709f20e233a688585e79ca5
1 parent
2deb5d87
option regexes
Showing
2 changed files
with
10 additions
and
2 deletions
src/cxxopts.hpp
src/main.cpp
| @@ -7,13 +7,12 @@ int main(int argc, char* argv[]) | @@ -7,13 +7,12 @@ int main(int argc, char* argv[]) | ||
| 7 | try | 7 | try |
| 8 | { | 8 | { |
| 9 | 9 | ||
| 10 | - std::basic_regex<char> options("--([a-zA-Z][-a-zA-Z]+)|-([a-zA-Z]+)"); | ||
| 11 | std::match_results<const char*> result; | 10 | std::match_results<const char*> result; |
| 12 | 11 | ||
| 13 | for (int i = 1; i < argc; ++i) | 12 | for (int i = 1; i < argc; ++i) |
| 14 | { | 13 | { |
| 15 | std::cout << "Argument " << i << std::endl; | 14 | std::cout << "Argument " << i << std::endl; |
| 16 | - std::regex_match(argv[i], result, options); | 15 | + std::regex_match(argv[i], result, cxxopts::option_matcher); |
| 17 | std::cout << "empty = " << result.empty() << std::endl; | 16 | std::cout << "empty = " << result.empty() << std::endl; |
| 18 | std::cout << "size = " << result.size() << std::endl; | 17 | std::cout << "size = " << result.size() << std::endl; |
| 19 | 18 |