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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |