Note that there are some explanatory texts on larger screens.

plurals
  1. POFast string splitting with multiple delimiters
    primarykey
    data
    text
    <p>I investigated some time here on StackOverflow to find good algorithms to split strings with multiple delimiters into a <code>vector&lt; string &gt;</code>. I also found some methods:</p> <p>The Boost way:</p> <pre><code>boost::split(vector, string, boost::is_any_of(" \t")); </code></pre> <p>the <code>getline</code> method:</p> <pre><code>std::stringstream ss(string); std::string item; while(std::getline(ss, item, ' ')) { vector.push_back(item); } </code></pre> <p>the tokenize way of Boost:</p> <pre><code>char_separator&lt;char&gt; sep(" \t"); tokenizer&lt;char_separator&lt;char&gt;&gt; tokens(string, sep); BOOST_FOREACH(string t, tokens) { vector.push_back(t); } </code></pre> <p>and the cool STL way:</p> <pre><code> istringstream iss(string); copy(istream_iterator&lt;string&gt;(iss), istream_iterator&lt;string&gt;(), back_inserter&lt;vector&lt;string&gt; &gt;(vector)); </code></pre> <p>and the method of Shadow2531 (see the linked topic).</p> <p>Most of them came from <a href="https://stackoverflow.com/questions/236129/how-to-split-a-string">this topic</a>. But they unfortunately don't solve my problem:</p> <ul> <li><p>Boost's split is easy to use but with the big data (about 1.5*10^6 single elements in best cases) and about 10 delimiters I am using it's horrific slow.</p></li> <li><p>The <code>getline</code>, STL and Shadow2531's method have the problem that I can only use one single char as delimiter. I need a few more.</p></li> <li><p>Boost's tokenize is even more horrific in the aspect of speed. It took 11 seconds with 10 delimiters to split a string into 1.5*10^6 elements.</p></li> </ul> <p>So I don't know what to do: I want to have a really fast string splitting algorithm with multiple delimiters. </p> <p>Is Boost's split the maximum or is there a way to do it <strong>faster</strong>?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload