You want to call /f$/ something that's anchored, but /\s+$/ can't be called anchored, because of what the optimizer can or cannot?

I don't think anyone will benefit if you let jargon depend on the current state of the optimizer. That would only be confusing - and it will expose the implementation. The meaning of /\s+$/ doesn't change whether the optimizer catches it or not. And if neither the meaning, nor the syntax changes, the name shouldn't change either.

IMO, /\s+$/ is anchored, because it will only match if there's whitespace in front of the end of the string - and it will match that whitespace. How the regex engine comes to that conclusion doesn't matter.

Your example as an example of anchoring being a misleading term is itself misleading. It's exactly doing what it means: it makes sure that what needs to be matched ends at the end of the line. Remove the anchor, and it'll match something else (the empty string). If the problem is in the anchoring, then it's because you don't have an anchor at the beginning of your match. Not that there's an easy anchor for that - never the less, the anchor at the end of the regex is correct. With a correct name. Which also explains why you aren't seeing replies "you aren't anchoring your regex to the end of the string". Because you are.

Perl --((8:>*

In reply to Re: The "anchor" misnomer in regexes by Perl Mouse
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.