The x option indicates that most white space should be ignored. That allows me to use spaces to break up the regex a little to make it easier to see where each field is.

The first field is captured by (\S+)\s+ which grabs the first sequence of non-space characters from the start of the line.

The second field is captured by ([^:]+):\s+ which matches and captures a sequence of characters excluding ':', then matches the ':' and any following white space.

The third field is a little more interesting. ((?:(?!\s*\(rev).)+))\s* crawls along the remainder of the line matching and capturing one character at a time until it comes to '(rev' preceeded by any amount of white space. The (?:...) bit groups some stuff without capturing. The (?!...) bit looks ahead to make sure the following stuff doesn't match whatever '...' is. The '...' bit inside of (?:...) matches a single character so long as it's not the start of something that would match '\s*\(rev'.

The fourth field just picks up everything from '(Rev' to the end of the line.


DWIM is Perl's answer to Gödel

In reply to Re^3: splitting lspci output by GrandFather
in thread splitting lspci output by rimmern

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.