Thanks choroba for setting me straight. If there's one thing that I keep forgetting to learn it's not to post regex questions or answers in haste. ;)

You are correct. This:

local $_ = 'foo'; m/\Gfoo/gc && say 'Matched foo'; m/\G.+/gc && say 'Matched dot star'; m/\G\z/gc && say 'Matched end of string';

...produces this:

Matched foo Matched end of string

And this:

local $_ = 'foo'; m/\Gfoo/gc && say 'Matched foo'; m/\G.*/gc && say 'Matched dot star'; m/\G\z/gc && say 'Matched end of string';

...produces this:

Matched foo Matched dot star

...indicating that end of string was consumed by dot star, though it's still a little odd because this also matches:

local $_ = 'foo'; m/\Gfoo/gc && say 'Matched foo'; m/\G.*\z/gc && say 'Matched dot star and end of string';

...produces this:

Matched foo Matched dot star and end of string

So while it may be eluded to in the documentation it's not entirely unsurprising. :)


Dave


In reply to Re^2: Seeking clarification on possible bug in regex using \G and /gc by davido
in thread Seeking clarification on possible bug in regex using \G and /gc by davido

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.