title: Read in data from text file line by line, separated by multiple delimiters in C++
body: <p>I have data in a text file which I wish to read in and split up to then create a new object out of. </p>
  
  <p>I have found this code:</p>
  
  <pre><code>std::ifstream file("plop");
  std::string   line;
  
  while(std::getline(file, line))
  {
      std::stringstream   linestream(line);
      std::string         data;
      int                 val1;
      int                 val2;
  
      std::getline(linestream, data, '\t');
  
      linestream &gt;&gt; val1 &gt;&gt; val2;
  }
  </code></pre>
  
  <p>Which reads in a text document and splits it by line. However this code assumes the delimiter is always a tab. What if the data had more than one delimiter which would point to what type of data would follow it. i.e assuming a text file such as:</p>
  
  <pre><code>hey, "hi" (hello) [hola]
  bye, "by" (byeee) [biii]
  </code></pre>
  
  <p>and I wanted to split the data into</p>
  
  <pre><code>String twoCharacters;
  String threeCharacters;
  String fourCharacters;
  String fiveCharacters;
  </code></pre>
  
  <p>so</p>
  
  <pre><code>twoCharacters = hi and by
  </code></pre>
  
  <p>with the delimiter being two " 
  and</p>
  
  <pre><code>threeCharacters = hey and bye
  </code></pre>
  
  <p>with the delimiter being a , after it</p>
  
  <p>Any help would be greatly appreciated! Thanks.</p>