title: Splitting a string into parts (with regexps?)
body: <p>The question originating from <a href="https://stackoverflow.com/a/53750697/856090">https://stackoverflow.com/a/53750697/856090</a> answer.</p>
  
  <p>We receive an "input" string.</p>
  
  <p>The input string is split into several "commands" by <code>+</code>s that is by <code>\s+\+\s+</code> regexp. However while splitting quoted <code>+</code> (<code>\+</code>) shall be ignored.</p>
  
  <p>Every command is then split into several "arguments" by whitespace characters, but quoted (<code>\</code>) whitespace is not counted on splitting and instead becomes a part of an argument.</p>
  
  <p>Quoted <code>\</code> (that is <code>\\</code>) becomes regular characted <code>\</code> and itself is not participated in quoting.</p>
  
  <p>My solution is to process the input string char-by-char with special behavior for <code>\</code>, <code>+</code>, and whitespace characters. This is slow and not elegant. I ask for an alternative solution (such as by using regexps).</p>
  
  <p>I write in Python 3.</p>
  
  <hr>
  
  <p>For example,</p>
  
  <pre><code>filter1 + \
  chain -t http://www.w3.org/1999/xhtml -n error + \
  transformation filter2 --arg x=y
  </code></pre>
  
  <p>transformation filter3</p>
  
  <p>becomes</p>
  
  <pre><code>[['filter1'],
   ['chain', '-t', 'http://www.w3.org/1999/xhtml', '-n', 'error'],
   ['transformation', 'filter2', '--arg', 'x=y']]
  </code></pre>
  
  <p>and</p>
  
  <pre><code>a \+ b + c\ d
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code> [['a', '+', 'b'], ['c d']]
  </code></pre>