Hey JM,
Good communication always demands some level of precision, and since regular expressions are very technical the necessary level of precision goes up when describing them.
A match.
A group.
A capture-group.
Are all considered to be separate entities.
(the\w+) # A capture-group.
(?:the\w+) # A non-capturing group.
So while we might talk about grouping part of the pattern, we should always distinguish that from a capture-group.
Match is entire match – and as you've seen the 'g' switch may produce multiple matches.
You can easily get tripped up in one of these online analyzers that emulate programming language level /search/replace/ code.
Without understanding how all the separators and switches work it's easy to get confused.
Many people mistakenly believe the forward slashes are part of the pattern, so I don't advise their use except as part of real code snippets.
$myStrVar =~ s/\w/•/g # Canonical Perl
$myStrVar =~ s!\w!•!g # My preference for pattern separation characters ('!').
Unless I'm talking to someone I know is versed in the syntax I'm using I find it more effective to explicitly separate search (or find) pattern, replace pattern, and switches.
Search Pattern:
<my search pattern>
Replace Pattern:
<my replace pattern>
Switches:
msixg
And when you're talking about a GUI regex environment it's usually more effective to present switches in-line in the pattern:
(?imx)<more pattern> # ON
(?-imx)<more pattern> # OFF
(?s-i)[a-z[:punct:][:blank:]]+ # MIXED
Another pitfall of regular expression analyzers is that you can get something working without understanding why it works. (Often true of Life in general of course.)
Using good vocabulary even when talking to oneself about RegEx helps us to understand them better. After 20 some-odd years of use and study I continue to learn new stuff, and I've found the need to tighten up my own vocabulary.
Hopefully this is more informative than pedantic .
-Chris