Ruby remove empty lines from string

后端 未结 5 1910
囚心锁ツ
囚心锁ツ 2021-02-03 10:51

How do i remove empty lines from a string? I have tried some_string = some_string.gsub(/^$/, \"\");

and much more, but nothing works.

5条回答
  •  臣服心动
    2021-02-03 11:04

    Originally

    some_string = some_string.gsub(/\n/,'')
    

    Updated

    some_string = some_string.gsub(/^$\n/,'')
    

提交回复
热议问题