Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 12.3 ('lJLaL')
Instant purchase and download via GumRoad!


Group-Ease (and Subgroup-Ease)

Everything You Need To Know About Subgroups

Issue: 12.3 (May/June 2014)
Author: Kem Tekinay
Author Bio: Kem Tekinay is a Macintosh consultant and programmer who started with Xojo when it was still REALbasic. He is the author of RegExRX (http://www.mactechnologies.com/index.php:i?page=downloads#regexrx), the popular regular expression editor for Mac and Windows.
Article Description: No description available.
Article Length (in bytes): 12,881
Starting Page Number: 87
Article Number: 12314
Related Web Link(s):


Excerpt of article text...

In the last column, I used a feature of regular expressions called "subgroups" (or "subexpressions") that I hadn't discussed previously, but it's such a core feature of regular expressions that it deserves an in-depth explanation.

Subgroup It

Let's say you have tab-delimited text with just two columns, but you want data from the second column only when the first has a particular value. (Yes, this is pretty easy to do with pure Xojo code, but for the sake of illustration, we are going to use a regular expression instead.)

You set up the RegEx with this pattern: ^Match Text\t.*. Translated, that is, start at the beginning of each line and look for the text "Match Text" followed by a tab, then grab all the text that follows it. Lines that have anything other than "Match Text" in the first column will be ignored.

Since you already know what's in the first column, you really only want the text after the tab, but you need to match the first column just to get the second. Sure, you can split the text in Xojo code, but we are going to let the RegEx do the work using a subgroup.

Change the pattern slightly to ^Match Text\t(.*). The parenthesis around the latter part of the pattern tells the RegEx engine to separate this portion of the match. The entire match is a "group" and the text in the second column is a "subgroup".

...End of Excerpt. Please purchase the magazine to read the full article.