title: Splitting a string with different start delimeter (not a duplicate)
body: <p>I need to split a big string which contains substrings encapsulated by either !="" or !"" but I am stuck now.</p>
  
  <p>The code I have </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;boost/regex.hpp&gt;
  #include &lt;boost/algorithm/string.hpp&gt;
  #include &lt;boost/algorithm/string/regex.hpp&gt;
  #include &lt;fstream&gt;
  #include &lt;cstring&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
      using namespace std;
      using namespace boost;
  
      std::string line;
  
      // Create vector to store matrix
      std::vector&lt; std::vector&lt;string&gt; &gt; vec_line;
      // Create temp vector to create "rows"
      vector&lt;string&gt;vec_string_temp;
  
  
  string add2vec_ele(string firste, string line)
  {
  
      // Add row
      vec_string_temp.push_back(firste);
      boost::algorithm::split_regex( vec_string_temp, line, regex( "(!=\"|!\")" ) ) ;
      // store row in vec_line
      vec_line.push_back(vec_string_temp);
      vec_string_temp.clear();
  return string();
  }
  
  
  int main()
  {
      string firste = "KeyWord";
      string line = "!=\"abcd!#efg\" !\"ABCDEFGHAG!/8765438\" !\"This !/[isanotherstring]?but nobody cares78\" !=\"again a string with equal sign and exclamation mark\"";
      add2vec_ele(firste,line);
  
      // print all elements
      for (unsigned int i = 0; i &lt; vec_line.size(); i++)
      {
          std::cout &lt;&lt; "Vector line: " &lt;&lt; i &lt;&lt; " ";
          for (unsigned int j = 0; j &lt; vec_line[i].size(); j++)
          {
              std::cout &lt;&lt; " Col: " &lt;&lt; j &lt;&lt; " " &lt;&lt; vec_line[i][j];
          }
          std::cout &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>basically does what I want, except that the -> != &lt;- or  -> !" &lt;- are lost.</p>
  
  <p>Input is stored in the string 'line'</p>
  
  <pre><code>string line = "!=\"abcd!#efg\" !\"ABCDEFGHAG!/8765438\" !\"This !/[isanotherstring]?but nobody cares78\" !=\"again a string with equal sign and exclamation mark\"";
  </code></pre>
  
  <p>The output from above code is</p>
  
  <pre><code>Vector line: 0  Col: 0  Col: 1 abcd!#efg"  Col: 2 ABCDEFGHAG!/8765438"  Col: 3 This !/[isanotherstring]?but nobody cares78"  Col: 4 again a string with equal sign and exclamation mark"
  </code></pre>
  
  <p>The expected output would be</p>
  
  <pre><code>Vector line: 0  Col: 0  Col: 1 !="abcd!#efg"  Col: 2 !"ABCDEFGHAG!/8765438"  Col: 3 !"This !/[isanotherstring]?but nobody cares78"  Col: 4 !="again a string with equal sign and exclamation mark"
  </code></pre>
  
  <p>How can I achieve this?</p>