This project contains both a left trim function and a right trim function. The demonstration simply uses both of these functions with an intermediate buffer. Trims both spaces and tabs, I couldn't get newlines to work properly.