fork(10) download
  1. text = '''"Value1", "Value2", "This is a longer piece
  2. of text with
  3. newlines in it.", "Value3"
  4. "Value4", "Value5", "Another value", "value6"'''
  5.  
  6. import re
  7. pattern = re.compile(r'".*?"', re.DOTALL)
  8. print pattern.sub(lambda x: x.group().replace('\n', ''), text)
  9.  
Success #stdin #stdout 0.01s 6680KB
stdin
Standard input is empty
stdout
"Value1", "Value2", "This is a longer piece    of text with    newlines in it.", "Value3"
"Value4", "Value5", "Another value", "value6"