title: python regex escape characters
body: <p>We have:</p>
  
  <pre><code>&gt;&gt;&gt; str
  'exit\r\ndrwxr-xr-x    2 root     root            0 Jan  1  2000 
  \x1b[1;34mbin\x1b[0m\r\ndrwxr-xr-x    3 root     root           
  0 Jan  1  2000 \x1b[1;34mlib\x1b[0m\r\ndrwxr-xr-x   10 root     
  root            0 Jan  1  1970 \x1b[1;34mlocal\x1b[0m\r\ndrwxr-xr-x    
  2 root     root            0 Jan  1  2000 \x1b[1;34msbin\x1b[0m\r\ndrwxr-xr-x    
  5 root     root            0 Jan  1  2000 \x1b[1;34mshare\x1b[0m\r\n# exit\r\n'
  
  &gt;&gt;&gt; print str
  exit
  drwxr-xr-x    2 root     root            0 Jan  1  2000 bin
  drwxr-xr-x    3 root     root            0 Jan  1  2000 lib
  drwxr-xr-x   10 root     root            0 Jan  1  1970 local
  drwxr-xr-x    2 root     root            0 Jan  1  2000 sbin
  drwxr-xr-x    5 root     root            0 Jan  1  2000 share
  # exit
  </code></pre>
  
  <p>I want to get rid of all the '\xblah[0m' nonsense using regexp. I've tried </p>
  
  <pre><code>re.sub(str, r'(\x.*m)', '')
  </code></pre>
  
  <p>But that hasn't done the trick.  Any ideas?</p>