how to extract the extensions entered by an user

the user enters "\.(cpp|h|hpp)" in command line argument.

how would i be able to extract all the extensions entered by the user and store it into a vector ?


such as vector<string> v = {".cpp", ".h" , ".hpp"} ;

notice that i would like to have a dot. infront of each extension.
You might use a stringstream with getline:

http://www.cplusplus.com/reference/sstream/stringstream/?kw=stringstream
http://www.cplusplus.com/reference/string/string/getline/?kw=getline

with the delimiter '|'. Remove all unnecessary charachter and prepend the '.'
if i do that how do i tell the program to start extraction with the opening parenthesis "(" and stop extraction at ")"
Since you're talking about command line parameters why not just have the user pass each extension as it's own parameter ie: yourProgramName cpp h hpp? Then you won't need to separate the values since they're already separated.

cuz the project requirements requires the user to enter a regex of form
"\.(cpp|h|hpp)" as a single command line argument
Your program receives command line arguments. More than one argument?
How do you know which argument has the "regexp"?

Lets assume that you know. You have one argument. A C-string. A null-terminated char array. A word.

Is there any other valid prefix for that word than the \.(?
Is there any other valid suffix for that word than the )?
Between those parentheses is then a vertical bar-delimited list of subwords?

You can find the positions of the opening and closing parentheses, can't you?
You can create a string object from such sequence?
my plan is to first extract the string cpp|h|hpp from

"\.(cpp|h|hpp)" (not sure how)


and then how do i transform the string cpp|h|hpp

into a vector

vector<string> v = {".cpp", ".h" , ".hpp"} ;
> cuz the project requirements
I would like to know the project requirements.
You don't properly describe your problem and you don't answer our questions.
Topic archived. No new replies allowed.