title: Regular expression to match comma or newline but not both
body: <p>I've got a problem with the following python script which extracts some options from text in an internal company web app text area.</p>
  
  <pre><code>import re
  
  text = 'option one\noption two, option three, option four'
  correct = 'option one, option two, option three, option four'
  
  pattern = re.compile('(\s*[,]\s*)')
  fixed = pattern.sub(', ', text)
  
  print fixed
  option one
  option two, option three, option four
  
  print fixed.split(', ')
  ['option one\noption two', 'option three', 'option four']
  </code></pre>
  
  <p>This obviously fails to split up 'option one\noption two' into 'option one', 'option two'</p>
  
  <p>So the input could end up as</p>
  
  <pre><code>option one
  option two, option three, option four
  </code></pre>
  
  <p>which would need to be converted to</p>
  
  <pre><code>option one, option two, option three, option four
  </code></pre>
  
  <p>it works fine if its a comma</p>
  
  <p>or</p>
  
  <p>a comma followed by a newline</p>
  
  <p>but not if its just a newline by itself.</p>