Search
Wednesday
Jul082015

Workflow Example: Text [Trim Whitespace]

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.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>