[Regex] Subexpression matching during search

I have probably missed something in the doc that answers my query but I just can’t see it. This is using Perl syntax. I had a regex: ^(XXX_\d{3,3})_\d{3,3}$ It compiles OK but does not match anything in a regex_search. If I remove the parenthesis ^XXX_\d{3,3}_\d{3,3}$ I get matches. Any clues as to what I am missing? Extract of regex related code lines: reg.regex = new boost::regex(reg.reg,boost::regex::perl | boost::regex::icase); boost::match_resultsstring::const_iterator match; boost::match_flag_type flags = boost::match_default; std::string::const_iterator xstart, xend; xrc = boost::regex_search(xstart,xend,match,*((*rgi).regex),flags); Larry

I have probably missed something in the doc that answers my query but I just can’t see it.
If the regex string is embedded in the C++ source then those backslashes will need to be doubled to \\d. Other than that I don't see anything wrong, can you please post a complete self-contained text case so we can see where you're going wrong? John.

"If the regex string is embedded in the C++ source then those backslashes will need to be doubled to \\d." Thanks John. The regex strings are read from file. For the example "^(XXX_\d{3,3})_\d{3,3}$" actually exists as ^(XXX_###)_###$ in the file and is converted programmatically to example string. The only ones that seem to fail are ones that begin with "^(.....". In strings like "^...(..." there doesn't seem to be a problem. The strings run against the regex are read from a database. Again, the odd thing is if I remove the parenthesis [^XXX_###_###$] it works and the correct strings are found. I'll do a bit of experimenting with it and will post a condensed test program if I can't pin it down. Larry -----Original Message----- From: John Maddock Sent: Friday, January 03, 2014 4:09 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Regex] Subexpression matching during search
I have probably missed something in the doc that answers my query but I just can’t see it.
If the regex string is embedded in the C++ source then those backslashes will need to be doubled to \\d. Other than that I don't see anything wrong, can you please post a complete self-contained text case so we can see where you're going wrong? John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
John Maddock
-
Larry