Workflow Example: Text [Trim Whitespace]08 Jul 2015
This workflow shows how to trim whitespace from lines of text. The workflow can trim leading whitespace, trailing whitespace or both together.
The workflow starts by defining some sample text. The first line has whitespace before and after the visible text. The second line has whitespace only before the visible text. The third line has whitespace only after the visible text and the final line is a control having no whitespace.
Next the workflow prompts you to select whether to trim before, after or at both ends of the lines of text. The choice then runs one of three different regular expressions that carry out the specified trimming request.
Once complete you are immediately offered a menu with two options. Copy the result to the clipboard or send it to Drafts (app). The reason these options are given rather than an Alert or a Quick Look action is simply because getting the content into another app suitable for plain text editing (e.g. with a monospaced font) will better show how the text has changed.