I used the regex you provided, and it seems for this the output is all 0s - unless I am doing something wrong

But you don't show what you're doing

$ perl - #!/usr/bin/perl -l -- $_ = q{Disk - HD 600GB 15K}; print / (\d+(?:\.\d+)?)GB\W/; __END__ 600 $ perl -Mre=debug - #!/usr/bin/perl -l -- $_ = q{Disk - HD 600GB 15K}; print / (\d+(?:\.\d+)?)GB\W/; Compiling REx " (\d+(?:\.\d+)?)GB\W" Final program: 1: EXACT < > (3) 3: OPEN1 (5) 5: PLUS (7) 6: DIGIT (0) 7: CURLYX[0] {0,1} (14) 9: EXACT <.> (11) 11: PLUS (13) 12: DIGIT (0) 13: WHILEM (0) 14: NOTHING (15) 15: CLOSE1 (17) 17: EXACT <GB> (19) 19: NALNUM (20) 20: END (0) anchored " " at 0 floating "GB" at 2..2147483647 (checking floating) m +inlen 5 __END__ Guessing start of match in sv for REx " (\d+(?:\.\d+)?)GB\W" against " +Disk - HD 600GB 15K" Found floating substr "GB" at offset 13... Found anchored substr " " at offset 4... Starting position does not contradict /^/m... Guessed: match at offset 4 Matching REx " (\d+(?:\.\d+)?)GB\W" against " - HD 600GB 15K" 4 <Disk> < - HD 600G> | 1:EXACT < >(3) 5 <Disk > <- HD 600GB> | 3:OPEN1(5) 5 <Disk > <- HD 600GB> | 5:PLUS(7) DIGIT can match 0 times out of 21474 +83647... failed... 6 <isk -> < HD 600GB > | 1:EXACT < >(3) 7 <sk - > <HD 600GB 1> | 3:OPEN1(5) 7 <sk - > <HD 600GB 1> | 5:PLUS(7) DIGIT can match 0 times out of 21474 +83647... failed... 9 < - HD> < 600GB 15K> | 1:EXACT < >(3) 10 <- HD > <600GB 15K> | 3:OPEN1(5) 10 <- HD > <600GB 15K> | 5:PLUS(7) DIGIT can match 3 times out of 21474 +83647... 13 <HD 600> <GB 15K> | 7: CURLYX[0] {0,1}(14) 13 <HD 600> <GB 15K> | 13: WHILEM(0) whilem: matched 0 out of 0..1 13 <HD 600> <GB 15K> | 9: EXACT <.>(11) failed... whilem: failed, trying continuat +ion... 13 <HD 600> <GB 15K> | 14: NOTHING(15) 13 <HD 600> <GB 15K> | 15: CLOSE1(17) 13 <HD 600> <GB 15K> | 17: EXACT <GB>(19) 15 <HD 600GB> < 15K> | 19: NALNUM(20) 16 <HD 600GB > <15K> | 20: END(0) Match successful! 600 Freeing REx: " (\d+(?:\.\d+)?)GB\W"

In reply to Re^3: Regex help! by Anonymous Monk
in thread Regex help! by lpanokarren

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.