Lynn Allan wrote:
ooops ... and thanks for the very prompt help to this regex newbie ... I'm very much at the "trial and error" state of getting regex statements to work.
Would one of the following be the preferred "assignment"? reg.assign("(\\
|\\ |\\ |\\ |\\ |\\)"); or reg.assign("\\<(and|can|did|the|in|a)\\>"); Both seem to work, but perhaps this regex newbie is missing a better alternative.
The latter looks more elegant to me. Make the opening parenthesis a (?: if you don't actually want to capture a sub-expression.
What is the "x modifier"? I looked up the perl explanation, and the boost::regex documentation, but that seemed related to formatting the statement itself.
Also, thanks for the time and effort you put into boost::regex ... development and ongoing support.
It causes whitespace in the expression to be ignored. You can turn it on in the flags passed to assign: reg.assign("\\<(and|can|did|the|in|a)\\>", boost::regex::perl|boost::regex::mod_x); Or you can embed it in the expression: "(?x)\\<(and | can | did | the | in | a)\\>" // whitespace ignored HTH, John.