On Wed, 21 Jul 2010 00:10:27 -0400, Steve Fábián
<> wrote:
|| I'm still playing with the @REGEX thing. In the latest incarnation of my
|plugin @XMATCH[], it returns the number of matches and sets the plugin
|_GMATCH to the number of groups matched.
|
|Possibly _GMATCH could return a set of integers, separated by space or
|comma, representing the number of matches for each group, in the same order
|as the groups. The function value itself could be the sum, i.e., the total
|number of matches. If you think counting nonzero values in _GMATCH is too
|much trouble for the user, you could add another internal variable, _GGROUP,
|the number of groups matched.
Unless I'm misunderstanding you, that's what it does now ... returns
the total number of matches and sets _GMATCH to the number of groups
matched.
I suppose I could create an array and put the individual group
match-counts there, or I could add a function @GMATCH[N] to get the
count for group N from the last @XMATCH, but I'm not sure it'd see
much application.
I find regexes (and the programming) interesting but I have little use
for them beyond the basics. Anyone who knows regexes well probably
also knows PERL or RUBY or some other way of using them more
efficiently.