title: Splitting a c++ string into two parts
body: <p>I'm trying to split a string that contains "|" into two parts. </p>
  
  <pre><code>if (size_t found = s.find("|") != string::npos)
  {
      cout &lt;&lt; "left side = " &lt;&lt; s.substr(0,found) &lt;&lt; endl;
      cout &lt;&lt; "right side = " &lt;&lt; s.substr(found+1, string::npos) &lt;&lt; endl;
  
  }
  </code></pre>
  
  <p>This works with "a|b", but with "a | b", it will have "| b" as the right side. Why is that? How can this be fixed?</p>