Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2005-11-22 12:41:47

Bugs item #1364007, was opened at 2005-11-22 09:41
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: regex
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: John Maddock (johnmaddock)
Summary: [Regex] Splitting string: last empty token is "compressed"

Initial Comment:
Last empty token is "compressed" when using regex_token_iterator for splitting strings.
BCB 5.64, boost 1.33.0
See the example, compare it with string_algo splitting:

#include <boost\regex.hpp>
#include <string>
#include <vector>
#include <iostream>
#include <boost/algorithm/string/finder.hpp>
#include <boost/algorithm/string/find_iterator.hpp>

void with_stringAlgo() {
  using namespace std;

  vector<string> result;
  string to_split("&|&_field2_&|&_field3_&|&");

  for(;i!=j;++i) {

  cout<<"size is "<<result.size()<<endl;
  for(int i=0;i<result.size();++i)

void with_regex() {
  using namespace std;
  using namespace boost;
  using namespace boost::regex_constants;
  string s("&|&_field2_&|&_field3_&|&");

  boost::regex r("&\|&");//use &|& as delimiter
  boost::sregex_token_iterator i(s.begin(),s.end(),r,-1,
  vector<string> v;
  cout<<"size is "<<v.end()-v.begin()<<endl;

int main() {


You can respond by visiting:

This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
Boost-bugs mailing list

Boost list run by bdawes at, gregod at, cpdaniel at, john at