title: Python - getting just the difference between strings
body: <p>What's the best way of getting just the difference from two multiline strings?</p>
  
  <pre><code>a = 'testing this is working \n testing this is working 1 \n'
  b = 'testing this is working \n testing this is working 1 \n testing this is working 2'
  
  diff = difflib.ndiff(a,b)
  print ''.join(diff)
  </code></pre>
  
  <p>This produces:</p>
  
  <pre><code>  t  e  s  t  i  n  g     t  h  i  s     i  s     w  o  r  k  i  n  g     
       t  e  s  t  i  n  g     t  h  i  s     i  s     w  o  r  k  i  n  g     1     
  +  + t+ e+ s+ t+ i+ n+ g+  + t+ h+ i+ s+  + i+ s+  + w+ o+ r+ k+ i+ n+ g+  + 2
  </code></pre>
  
  <p>What's the best way of getting exactly:</p>
  
  <p><code>testing this is working 2</code>?</p>
  
  <p>Would regex be the solution here?</p>