for ($text) { s/^\s+//gm; s/\s+$//gm; s/(\s)\s+/$1/g; } [download]
In reply to Re^4: removing redundantwhitespace by ikegami in thread removing redundantwhitespace by Anonymous Monk