Guest User

Untitled

a guest
Oct 21st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. "this line break must stay.
  2. but this one
  3. not."
  4.  
  5. "this line break must stay.
  6. but this one not."
  7.  
  8. import re
  9. p = re.compile('(?<!(?|!|.))n', re.MULTILINE)
  10. text = "hello,nMy name is Hal.nHow arenyou doing?n"
  11. re.sub(p, ' ', text)
  12. # outputs:
  13. 'hello, My name is Hal.nHow are you doing?n'
Add Comment
Please, Sign In to add comment