fork download
  1. re = /(?:\R\K|\G) /
  2. str = ' - first
  3. - second
  4.  
  5. this is a test
  6.  
  7. - first
  8. - second
  9. '
  10. result = str.gsub(re, ' ')
  11.  
  12. puts result
Success #stdin #stdout 0.01s 6216KB
stdin
Standard input is empty
stdout
  - first 
  - second

this is a test

  - first 
  - second