Moving Forward
In this article, I’ve barely scratched the surface of what you can do with regular expressions. When you embed sets of parentheses (()) in your patterns, you can locate patterns as well as portions of patterns; then you can use these substrings in replacements, for example.
That’s just the beginning. Regular expressions possess an enormous amount of string-processing power. Entire books have been written on the subject, and I encourage you to check out the sources I mentioned earlier. One exercise you might try is to come up with a regular expression that strips away all the tags from an HTML file, leaving only the plain text. Or one that creates a simpler version of the text for use on small device screens. Whereas somebody not familiar with regular expressions might be inclined to start writing some complex (and possibly bug-ridden) algorithms to solve such problems, they can often be solved with simple regular expressions. Of course, some regular expressions are themselves complex and bug-ridden, but in my experience, the bugs in regular expressions are usually easier to manage, and in the end far less time is spent developing with regular expressions than without.
Regular expressions are an exciting topic and extremely useful. When you master them and put them to use with the help of a good library such as boost::regex, you’ll wonder how you ever lived without them.