What are you proving? The \s+ part will start as far on the left as it can, and since your string is all newlines and you’re always using \s when you ask for character matches and have turned on /m, all character matches can match anywhere and the $ can match between any characters. So you’re not actually saying anything. No part of your pattern is constrained in any way, given the data you’re running it against.

I guess the bit I wrote about firstness does not actually say anything either, since “whichever is first” means “whichever is left-most” anyway and at any location between characters, only one of these conditions can be true. So $ in multiline mode matches before any newline or before the end of the string, and that’s that.

Makeshifts last the longest.


In reply to Re^4: The "anchor" misnomer in regexes by Aristotle
in thread The "anchor" misnomer in regexes by japhy

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.