Adding a "\n" in front of a line


#1

assuming I have a field "field1" with value "Hello world"

How can I make the value become "\nHello world"

When I gsub it will always become "\n"HelloWorld"


(Guy Boertje) #2

You can use the unicode escaped character.

"Hello World".gsub("Hello", "\u000aHello")
=> "\nHello World"

(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.