I compiled the above example because I was trying to understand the embedded for loop. If anyone can explain the concept of the sub-matching, I would appreciate it. In the specific expression used, I can understand the three matches because there are three words that start with "sub". However, I'm not understanding the concept of the sub-matching (no pun intended). The example prints
subject sub ject
I'm not sure why "ject" is a sub match. Perhaps I am just in need of a clearer explanation of that particular regular expression that is used within the example so that I can learn to appreciate the capability of the smatch class.