|
Boost : |
From: SourceForge.net (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:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1364007&group_id=7586
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:
toto_lists_at_[hidden]
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_&|&");
boost::split_iterator<string::iterator>
i(to_split.begin(),to_split.end(),boost::first_finder("&|&")),j;
for(;i!=j;++i) {
result.push_back(boost::copy_range<std::string>(*i));
}
cout<<"size is "<<result.size()<<endl;
for(int i=0;i<result.size();++i)
cout<<result[i]<<endl;
}
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,
match_default),j;
//
vector<string> v;
copy(i,j,back_inserter(v));
//
cout<<"size is "<<v.end()-v.begin()<<endl;
copy(v.begin(),v.end(),ostream_iterator<string>(cout,"\n"));
}
int main() {
with_stringAlgo();
with_regex();
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1364007&group_id=7586
-------------------------------------------------------
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:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk