No idea what you are asking.
¿What's the purpose of your program?
> so if the user enters ".(c|cpp)" or ".(abb|4f5)" as command line argument
¿you want the user to enter a regex and you want to
validate that regex?
¿just validate it but never run it?
> so if the user enters ".(c|cpp)" or ".(abb|4f5)" as command line argument it
> will check if the string input by the user matches ext.
but then you write
string input = ".(abb|4f5)" ;
¿so input is the regex? ¿or input is something like `main.cpp'?
> a single slash \ and quotation marks needs to be escaped when entering as
> command line argument.
> Therefore i have entered \"\\.(cpp)\" as one of my command line arguments in VS.
your shell has defined some special characters with an associated behaviour. For example an space would limit the command line arguments.
If you want to send the character itself instead of invoking its behaviour, you need to escape it.
So if you wrote
then your program would have
argv[0] = ./a.out
argv[1] = "\.(cpp)" |
Read argv[1] carefully, you have a quote, a backslash, a dot...
Now look at your ¿regex validator?
regex ext(R"raw("\.\([[:alpha:][:digit:]]*\)")raw");
It reads, starts with a quote, then comes a dot...
¿do you understand why it failed? Your test string has a backslash that is not matched by the regex.
>
const std::string regex_string = R"(\\\\.(\w+\))";
¿what are you doing now? ¡you've got four backslashes in a row!
¿what did you intend to match?
> but im still curious, why is that i have to escape the quotation marks when i
> type in command line arguments , but i don't need to escape the parentheses
> "(" and ")" and the dot "." with a double slash "\\" ?
because the dot has no especial meaning for your shell.
> is there anyway i can make it work so that the user does not even have to
> escape the quotation marks \"
that's the behaviour of your shell, and your program has no right to modify it.
You may just stop using command line arguments and get the input with std::cin
> i would like to have the user to enter something like this "\.(cpp|hpp|h)" .
> is there an regex expression for that ?
¿a regex for what?
Again, ¿what's the purpose of your program?