
13 Dec
2001
13 Dec
'01
9:39 a.m.
Hi all, I'm trying to match strings of the form "a&b&c&d" with the following expression: "(?:([^&]+)&)*([^&]+)". This nicely matches the whole string but instead of giving me the submatches "a", "b", "c" and "d" I just get "c" and "d". Could anyone tell me what I'm doing wrong? Sample code, tested with MSVC6SP5 and Boost 1.26.0: #include <boost/regex.hpp> #include <string> #include <iostream> void main(void) { const char *input ="a&b&c&d"; const boost::regex syntax("(?:([^&]+)&)*([^&]+)"); boost::cmatch matches; if(boost::regex_match(input, matches, syntax)) { for (boost::cmatch::size_type i = 0; i < matches.size(); ++i) std::cout << static_cast<std::string>(matches[i]) << '\n'; } } Tia, Markus