I'll bet you 100 hours of my time on any (on-line accessible) project of your choosing, that if we do a survey of the regex uses on this site, not only will most of them be targeted at single line strings, an overwhelming majority will be targeted at single line strings.

No bet. I don't doubt that most regexes uses are single-line oriented. I never claimed otherwise. What I said was that people far more often use ^ as start-of-line instead of start-of-string.

But that's what makes the defaults of ^ and $ so unfortunate. Because they happen to work okay most of the time (i.e. line-by-line), they only bite people when those people attempt something less usual and more intrinsically difficult (such as multiline parsing).

And once you squash the idea that matching against multi-line strings is the norm, giving away the heads-up that seeing those options explicitly stated should give the programmer, in favour of cargo-culting a 'throw it all in there cos it probably won't cause any problems' mandate, is a really bad idea in my book. In preference to asking the programmer to look up the documentation when they need it is dangerous.

Yes, that's fine for good programmers, such as yourself. But the problem is that most programmers don't know they need those options. They think regexes already work as if /s and /m are already on.

Every time educationalists have tried to "simplify the learning process", by dumbing down, it has increased the pass rate but also wholly devalued it. There's no point in having more people pass if they don't understand how to apply what they've learnt.

This has nothing to do with simplifying any learning process. It has to do with making Perl work better (and, in particular, work better with the weaknesses and blindspots of human nature). I have argued that habitual use of /xms does that. You disagree. That's your right and privilege.

However, the fact that Perl 6 has (the equivalent of) /s on by default, and also does away with /m by offering separate always-on start-of-line/end-of-line anchors suggests that I'm not alone in believing that permanent /ms is the more appropriate default.

Damian


In reply to Re^6: example of 'm / / m' related example and compare to 'm / / s' by Anonymous Monk
in thread PERL regex modifiers for m// by rockstar99

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.