title: Extract substring defined by start and end strings (C++)
body: <p>Given <code>std::wstring text</code>, <code>std::wstring start</code>, <code>std::wstring end</code>, the goal is to extract <code>std::wstring text_out</code> - containing text in between <code>start</code> and <code>end</code> - if they exist in <code>text</code>.</p>
  
  <p>Note: if multiple matches to <code>start</code> exist - consider first one, for <code>end</code> - consider the last match.</p>
  
  <p>This works, but is there more elegant solution?</p>
  
  <pre><code>boost::iterator_range&lt;wstring::iterator&gt; it_start = boost::find_first( text, start);
  boost::iterator_range&lt;wstring::iterator&gt; it_end = boost::find_last( text, end);
  
  if (it_start.empty() == false &amp;&amp; it_end.empty() == false)
  {
      text_out.assign( it_start.begin(), it_end.end() );
  }
  else if ( it_start.empty() == false &amp;&amp; it_end.empty() == true )
  {
      text_out.assign( it_start.begin(), text.end() );
  }
  else if ( it_start.empty() == true &amp;&amp; it_end.empty() == false )
  {
      text_out.assign( text.begin(), it_end.end() );
  }
  </code></pre>