【发布时间】:2021-01-13 14:30:53
【问题描述】:
我有以下文件:
Some code...
Some more code...
@NiceFunction
Function content
More function content
@End
Even more code...
现在我使用 Ruby 将其读入字符串,并希望将 @NiceFunction 和 @End 之间的所有内容替换为不同的内容。
我尝试了string.gsub! /@NiceFunction(.*)@End/, "some other function content",但这似乎不适用于换行符。
我也试过string.gsub! /@NiceFunction([.\n]*)@End/, "some other function content",没有成功。
【问题讨论】:
标签: ruby string replace newline