QA Graphic

Parse text using TextExpander

I have to use BuildBot to build branches for testing. This means that I have to fill out a bunch of fields to successfully build the developer box:

buildbot2.jpg

Developers are required to create branches with the Jira Ticket number in it, such as this:

XXX-12028-end-of-bugs

To make life easier I created a TextExpander snippet to quickly fill in all the fields in one quick abbreviation. In order to do this, I created a 'helper' Javascript snippet to parse the clipboard text to the Jira issue number out. I'll use this Jira number in the 'reason' field so other people will know what issue I am testing.

Step 1: Create a 'GrepJira' Javascript snippet:

This Javascript code will search for 'XXX-1111' in the clipboard text, you should change the text to whatever three digits for your Jira ticket:

var re = /(XXX-d{2,5})/i;
var str = "%clipboard";
var m;

if ((m = re.exec(str)) !== null) {
if (m.index === re.lastIndex) {
re.lastIndex++;
}
// View your result using the m-variable.
// eg m[0] etc.
}

m[0];

I assigned 'GrepJira' as the abbreviation to this snippet. Perhaps a better strategy would be to use tm_GrepJira as an abbreviation, since it's for use only within TextExpander.

Step 2: Create the main snippet that will be used.

This is pretty much entering in a bunch of text separated with some pre-selected data:
cryan%key:tab%qa %snippet:GrepJira%
%key:tab%%clipboard%key:tab%

This is what it looks like using the above example branch name:

buildresults.jpg

To make it a bit easier, I color coded the fields with the text snippet. Hope this helps you get a general idea on how I use parsing text within TextExpander. Hope it helps you create some cool text snippets!

 

About

I find TextExpander, by Smile on My Mac, to be an awesome productivity tool. This past winter, I posted some cool snippets that demonstrate the power of the application. Occasionally, I will post some new snippets that I think will be useful in anyone's TextExpander library.

Schedule

WednesdayAffinity
ThursdayBBEdit
FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
MondayMedia Monday
TuesdayQA