Groovy web console

subscribe to the feed Subscribe
to this

What You See Is What You Almost Get

Published 8 months ago by MS with tags No break spaces
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
//Ideal output
String idealSentance = "Many    spaces   between   each   word"

//Current WYSIWYG output
String outputSentance = "Many    spaces   between   each   word"

StringBuilder sb = new StringBuilder()
//Loop through each new word
outputSentance.split(" ").each{
        sb.append(it).append(" ")
    } else {
        sb.append(" ")

String resultantSentance = sb.toString().trim()
println resultantSentance 

(resultantSentance ==idealSentance)