I am considering input files with lines like
\"20170103\",\"MW JANE DOE\",\"NL01 INGB 1234 5678 90\",\"NL02 INGB 1234 5678 90\",\"GT\",\"Af\",\"12,34\",\"Interne
As others have said, regex_iterator::operator-> returns a match_results and match_results::str is defaulted to 0:
The first
sub_match(index0) contained in amatch_resultalways represents the full match within a target sequence made by aregex, and subsequentsub_matchesrepresent sub-expression matches corresponding in sequence to the left parenthesis delimiting the sub-expression in theregex
So the problem with your code is you're not using linePart = it->str(1).
A better solution would be to use a regex_token_iterator. With whitch you could just use your re to directly initialize lineParts:
vector lineParts { sregex_token_iterator(cbegin(line), cend(line), re, 1), sregex_tokent_iterator() };
But I'd just like to point out that c++14 introduced quoted does exactly what you're trying to do here, and more (it even handles escaped quotes for you!) It'd just be a shame not to use it.
You probably are already getting your input from a stream, but just in the case you're not you'd need to initialize an istringstream, for the purposes of example I'll call mine: line. Then you can use quoted to populate lineParts like this:
for(string linePart; line >> quoted(linePart); line.ignore(numeric_limits::max(), ',')) {
lineParts.push_back(linePart);
}
Live Example