$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: markus_schoepflin (markus.schoepflin_at_[hidden])
Date: 2001-12-13 04:39:52
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