Re: RFC 110 (v3) counting matches

[email protected] (Damien Neil)
Newsgroups perl.perl6.language.regex
Message-ID <[email protected]>
On Mon, Aug 28, 2000 at 06:05:03PM -0400, Mark-Jason Dominus wrote:
>         # WRONG
>         while (($mo, $dy, $yr) = ($string =~ /\d\d-\d\d-\d\d/g)) {
>           ...
>         }

I assume you mean:
  while (($mo, $dy, $yr) = ($string =~ /(\d\d)-(\d\d)-(\d\d)/g)) {
    ...
  }

Drawing on some of the proposals for extended 'for' syntax:
  for my($mo, $dy, $yr) ($string =~ /(\d\d)-(\d\d)-(\d\d)/g) {
    ...
  }

This still requires that you know how many () matching groups are in
the RE, of course.  I don't think I would consider that onerous.

I agree that REs currently have a somewhat confusing mass of behaviors,
depending on context and the /g option.  I'm not certain if this can
be fixed without adding still more RE /options (and more confusion),
or more verbosity.

Do you have specific suggestions on how REs could be made "more
orthogonal"?

                       - Damien
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.