Hello all,

I have another regexp question (seems to be my favorite topic).

I'm trying to parse the output of a cli command, and I'm looking for string, in each output line, that consists of digits seperated by periods. i.e.

0.1.4.1 0.1.5.2 0.1.6.3 0.1.7.4
but, my problem is, I don't want to capture the output if the 3 field, from the left, is a 0,1,2, or 3. But, it can start with it. I have this snippet:
if ( /.*(\d+\.\d+\.[4-9]\.\d+).*/ ) { print "$1 <br> \n"; }
But this will not work if the 3rd field is a double digit.

So, to elaborate more, the following I want to ignore:

0.1.1.1 0.1.2.2 0.1.3.3
but, these I do want to capture:
0.1.10.1 0.1.20.2 0.1.30.3
Basically, if the 3rd field is > 3, I want to capture it.

Any thoughts on to do this ???? Thx.

20040519 Edit by Corion: Changed title from 'Another regular expression'


In reply to Question about conditional regex capture by TASdvlper

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.