I have the following string :
s = "server ('m1.labs.terada')ta.com') username ('user5') password('use r5') dbname ('default')";
I have defined a regex for extracting the values between the paranthesis,i.e m1.labs.terada')ta.com , user5.
regex re("\(\'[!-~]+\'\)");
sregex_token_iterator i(s.begin(), s.end(), re, 1);
sregex_token_iterator j;
However, I am not able to extract 'use r5'. Is there any way I can modify the regex to include white spaces as well?
!
and a~
. Your regular expression deliberately excludes it. Perhaps it shouldn't. – Nubblym1.labs.terada')ta.com') username ('user5') password('use r5') dbname ('default
one big token? In other words, your grammar is ambiguous. You first need to come up with a precise definition of "token" that excludes the above, but still includesm1.labs.terada')ta.com
anduse r5
. Spell this out in plain English, and perhaps we'd be able to come up with a regex that formalizes this description. – Nubblym1.labs.terada')ta.com') username ('user5') password('use r5') dbname ('default
should not be considered a valid token. What rules on token syntax does it violate? Just saying "I want this" is not enough; DWIM system has yet to be perfected. – Nubblym1.labs.terada')ta.com') username ('user5') password('use r5') dbname ('default
is in fact enclosed in('
and')
. If that's the rule, then it looks like you got the correct answer. If you don't consider this to be the correct answer, you need to figure out what's wrong with it, and formulate a different rule or set of rules. – Nubbly