... I think I would take issue with your second paragraph.
... the unvarying use of the /xms regex modifier 'tail' ...
While they are very rarely used that way, m, s and even x are no more invariant than i ...

What I meant to convey by my reference to "/xms-tail invariance" was that this is the PBP recommendation (original post amended) and that the reason for this is to nail down the behavior of the  ^ $ . critters. For this reason, I regard with horror the idea of sprinkling  (?-x) (?m) (?-s) et al through the regex due to the extreme danger of brain meltdown and subsequent containment breach. For those cases in which one might be tempted to the Dark Side, e.g., the use of  (?-s:.) in case an "anything-but-a-newline" match is needed (always assuming an /xms tail), PBP discusses alternatives; in the foregoing example,  [^\n] (or in 5.12+, the "experimental"  \N sequence).

I'm also under the impression that (?i) need not be confined solely to the scope of capturing and non-capturing groups ...

My discussion of the behavior of  (?pimsx-imsx) patterns was brief, vague and lacking. I've tried to remedy this with a link to the docs.

The following patterns are examples of how I understand the modifiers can be used ...

I haven't tested these, but they look syntactically correct. However, I would quibble with most, especially the latter ones, on stylistic grounds. I haven't time now, but may return to this point with a detailed discussion of my own preferences.

PBP is a fascinating book with very well argued recommendations ...

I agree with every statement in this paragraph.


In reply to Re^5: Capturing string matched by regex by AnomalousMonk
in thread Capturing string matched by regex by tunafish

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.