Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在多行而不是一行中编写一个很长的 xml 请求?当我在多行中编写它时,由于插入了换行符,该字符串不被接受。如何在文本编辑器中添加换行符并在实际程序中添加换行符?我正在使用崇高。
str = "this is \n multi-line \n text \n\n" puts str # this is # multi-line # text
使用gsub!修改字符串
str.gsub!("\n","") puts str # this is multi-line text
使用squish删除所有不必要的空白
str = "this is \nmulti-line \n text \n\n" puts str.squish # this is multi-line text