option regexes
This commit is contained in:
parent
2deb5d87fb
commit
de73da53b5
@ -1 +1,10 @@
|
||||
#include <regex>
|
||||
|
||||
namespace cxxopts
|
||||
{
|
||||
std::basic_regex<char> option_matcher
|
||||
("--([a-zA-Z][-_a-zA-Z]+)(=(.*))?|-([a-zA-Z]+)");
|
||||
|
||||
std::basic_regex<char> option_specifier
|
||||
("(([a-zA-Z]),)?([a-zA-Z][-_a-zA-Z]+)");
|
||||
}
|
||||
|
||||
@ -7,13 +7,12 @@ int main(int argc, char* argv[])
|
||||
try
|
||||
{
|
||||
|
||||
std::basic_regex<char> options("--([a-zA-Z][-a-zA-Z]+)|-([a-zA-Z]+)");
|
||||
std::match_results<const char*> result;
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
std::cout << "Argument " << i << std::endl;
|
||||
std::regex_match(argv[i], result, options);
|
||||
std::regex_match(argv[i], result, cxxopts::option_matcher);
|
||||
std::cout << "empty = " << result.empty() << std::endl;
|
||||
std::cout << "size = " << result.size() << std::endl;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user