Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know about the boost::string library but using the boost regex_token_iterator you'll be able to express delimiters in terms of regular expression. So yes, you can use quoted delimiters, and far more complex things as well.</p> <p>Note that this used to be done with regex_split which is now deprecated.</p> <p>Here's an example taken from the boost doc:</p> <pre><code>#include &lt;iostream&gt; #include &lt;boost/regex.hpp&gt; using namespace std; int main(int argc) { string s; do{ if(argc == 1) { cout &lt;&lt; "Enter text to split (or \"quit\" to exit): "; getline(cin, s); if(s == "quit") break; } else s = "This is a string of tokens"; boost::regex re("\\s+"); boost::sregex_token_iterator i(s.begin(), s.end(), re, -1); boost::sregex_token_iterator j; unsigned count = 0; while(i != j) { cout &lt;&lt; *i++ &lt;&lt; endl; count++; } cout &lt;&lt; "There were " &lt;&lt; count &lt;&lt; " tokens found." &lt;&lt; endl; }while(argc == 1); return 0; } </code></pre> <p>If the program is started with <strong>hello world</strong> as argument the output is:</p> <pre><code>hello world There were 2 tokens found. </code></pre> <p>Changing <em>boost::regex re("\s+");</em> into <em>boost::regex re("\",\"");</em> would split quoted delimiters. starting the program with <strong>hello","world</strong> as argument would also result in:</p> <pre><code>hello world There were 2 tokens found. </code></pre> <p>But I suspect you want to deal with things like that: <strong>"hello", "world"</strong>, in which case one solution is:</p> <ol> <li>split with coma only</li> <li>then remove the "" (possibly using boost/algorithm/string/trim.hpp or the regex library).</li> </ol> <p>EDIT: added program output</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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