I have a string:
s = "server ('m1.labs.terada')ta.com') username ('user5') password('user)5') dbname ('default')";
I am extracting the argument names: such as server, username..., dbname.
To do this I am using the following regex:
regex re("\\(\'[!-~]+\'\\)");
sregex_token_iterator i(s.begin(), s.end(), re, -1);
sregex_token_iterator j;
unsigned count = 0;
while(i != j)
{
string str1 = *i;
cout <<"token = "<<str1<< endl;
i++;
count++;
}
cout << "There were " << count << " tokens found." << endl
For this the output I am getting is :
token = server
token = username
token = password
token = dbname
token =
There were 5 tokens found.
How shall I avoid the 5th token formed. Am I missing out on anything?