Processing Groups and Captures

So far you've seen how to split strings and parse strings based on supplied patterns with specialized (meta-) characters. Now you'll take what you've learned a step further and discover the world of groups and captures. However, before we get into the technical details of how to work programmatically with groups and captures, let's cover what they are and what services they provide.

Grouping has two purposes. One is to designate captures—to specify a smaller part of a larger match that contains a string that you wish to extract or isolate. In this vein, groups can be thought of as “sub-matches.” An example of this would be in working with strings containing U.S. telephone numbers. Groups would come into play in ...

Get Extending MFC Applications with the .NET Framework now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.