I have a value like this:
Supoose I have a string:
s = "server ('m1.labs.teradata.com') username ('u\'se)r_*5') password('uer 5') dbname ('default')";
I need to extract
- token1 :
'm1.labs.teradata.com'
- token2 :
'u\'se)r_*5'
- token3 :
'uer 5'
I am using the following regex in cpp:
regex re("(\'[!-~]+\')");
sregex_token_iterator i(s.begin(), s.end(), re, 0);
sregex_token_iterator j;
unsigned count = 0;
while(i != j)
{
cout << "the token is"<<" "<<*i++<< endl;
count++;
}
cout << "There were " << count << " tokens found." << endl;
return 0;
'[^']+'
– Untoldstr(1)
to get the capturing group #1 value. – Reedingsregex_token_iterator
rather than the regular one? – Florentinaflorentinestart = std::string::find('\'')
to find the beginning of the target text and then useend = std::string::find('\'', start)
to find the end. – Catheryncatheterusername ('u\\'se)r_*5')
please correct you question or even better provide minimal reproducible example – Untold