[Boost-bugs] [ boost-Bugs-1364007 ] [Regex] Splitting string: last empty token is "compressed"

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@hotbox.ru 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/boost-bugs
participants (1)
-
SourceForge.net