Split by size of characters but include words entirely in Python regex
<p>There is a task in Codefights which says <em>given a feedback and the size of the screen, splits the feedback into lines so that</em>:</p>

<ul>
<li><p>each token (i.e. sequence of non-whitespace characters) belongs to one of the lines entirely;</p></li>
<li><p>each line is at most size characters long;</p></li>
<li><p>no line has trailing or leading spaces;</p></li>
<li><p>each line should have the maximum possible length, assuming that all lines before it were also the longest possible.</p></li>
</ul>

<p>The requirement is that it should be solved with one line only.</p>

<p>I believe <code>regex</code> should help and I tried this:</p>

<pre><code>re.split(r'(?&lt;=.{8})\s', "This is an example feedback", re.I)
</code></pre>

<p>to get this:</p>

<pre><code>['This is an', 'example', 'feedback']
</code></pre>

<p>instead of:</p>

<pre><code>["This is", "an", "example", "feedback"]
</code></pre>

<p>Obviously it does not satisfy a couple of conditions.</p>

<p>Just a hint toward what regex concept could help here would be awesome.</p>

<p>Thank you.</p>