Replacing Matches Using Groups and Substitution Patterns

In the previous two sections, you've learned how to group and capture submatches and how to replace text. This section shows you how to combine those two capabilities with substitution patterns to give you an even more powerful means of manipulating text. Substitution patterns are just special characters that tell the Regular Expression engine how you want text replaced. Table 2-4 shows the available substitution characters that can be used.

Of special importance in Table 2-4 are the first two patterns, which allow us to specify groups in the capture and then use those group names in the replacement. Let's see how to do that with an example that converts between U.S. (mm/dd/yyyy) and European ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.