Remove all the spaces from a string. It is like trim, trim-left, and trim-right together.

examples/groovy/remove_spaces.gvy

def input_text = " hello world "
clean_text = input_text.replaceAll("\\s","")
println("'${input_text}'")   // ' hello world '
println("'${clean_text}'")   // 'helloworld'

$ groovy remove_spaces.gvy

' hello world '
'helloworld'

Without the need to doubl-escape using ~//

examples/groovy/remove_spaces_no_escape.gvy

def input_text = " hello world "
clean_text = input_text.replaceAll(~/\s/,"")
println("'${input_text}'")   // ' hello world '
println("'${clean_text}'")   // 'helloworld'

groovy remove_spaces_no_escape.gvy