Groovy web console

subscribe to the feed Subscribe
to this
site

remove crlf

Published 1 month ago by Thiago Veronezi
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def original = "a\n\rb\n\r" // CRLF (Windows)
println("Original = \n${original}")
// removing all the new lines by spliting the string into a list, then joining it back with \n
def result = original .split("[\r\n]").findAll({it}).join("\n") 
println("Result = \n${result}")