Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Just a point here - something I finally got only after a number of rereadings of the section in J. Friedl's excellent Mastering Regular Expressions (O'Reilly) the /m and /s are a little more complicated.
/m: better remembered as 'multi' mode - affects 'multiple' (2) meta chars, the anchors (^ and $)
/s: 'single' mode - affects one meta char, the dot '.'

/s changes the dot's normal definition - match any char except a new line (\n). In single mode the dot can match \n too which allows regex phrases like:

to match across the end of line. That all it does and so its why the "item.*" in your example matches the end of line.
/m changes the ^ and $ anchors from absolute beginning and end of string to match beginning and end of a line, as marked by new line chars. Which is useful w/ the '/g' option, for example:

local $/ = undef; my $whole_file = <>; # slurp while ( $whole_file =~ /^(.*)$/mg ) { # process line by line print "Got: $1\n"; }
Not a useful snippet but ... two notes - the '\n' on the print stmt and notice the diff if you put an 's' in the match options


In reply to Re^4: Regex Tool by a
in thread Regex Tool by Yunus

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (4)
    As of 2017-06-27 12:24 GMT
    Find Nodes?
      Voting Booth?
      How many monitors do you use while coding?

      Results (604 votes). Check out past polls.