title: Why does this re.split() return white space as separate items in the list?
body: <p>I am using this code to split a string at <code>\.*[\s$]</code>, but preserving the split characters as an item in the list:</p>
  
  <pre><code>import re
  
  markup = r"\{caption Figure 1: Leaf shapes\} \image:leaf_shapes.tiff"
  tokens = re.split(r'(\.*[\s$])', markup)
  </code></pre>
  
  <p>I expected it to return this list:</p>
  
  <pre><code>['\\caption ', 'Figure 1: Leaf shapes', '\\} ', '\\image:leaf_shapes.tiff']
  </code></pre>
  
  <p>But instead I get this:</p>
  
  <pre><code>['\\{caption', ' ', 'Figure', ' ', '1:', ' ', 'Leaf', ' ', 'shapes\\}',
   ' ', '\\image:leaf_shapes.tiff']
  </code></pre>
  
  <p>Why are white spaces returned as separate items in the list?</p>
  
  <h3>Edit</h3>
  
  <p>I was supposed to escape the backslash, not the period, so I've changed my code to this:</p>
  
  <pre><code>markup = r"\{caption Figure 1: Leaf shapes\} \image:leaf_shapes.tiff"
  tokens = re.split(r'(\\.*[\s$])', markup)
  </code></pre>
  
  <p>But now I get this result:</p>
  
  <pre><code>['', '\\{caption Figure 1: Leaf shapes\\} ', '\\image:leaf_shapes.tiff']
  </code></pre>
  
  <p>Please look at my expected result so you know what I'm trying to achieve.</p>