Hello huck, and welcome to the Monastery!

But i still cant understand why the \d* in content2 was not greedy enough to capture all of the '39', instead taking the '9' to be NOT ';' .

Actually, that’s exactly what it did do — at first. But that didn’t lead to a match, because 39; doesn’t match \d*[^;]. So, as Corion says, the regex had to give up the last character and try again, giving 39, which does match. “Greedy” means as greedy as possible while still matching. This is explained in detail in the Camel Book (which I don’t have to hand) in a section called “The Little Engine That /Could(n’t)?/”

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: RE greediness by Athanasius
in thread RE greedyness by huck

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.