On Sat, 1 Dec 2001, linkagent wrote: > ----- Original Message ----- > From: "$Bill Luebkert" <[EMAIL PROTECTED]> > To: "linkagent" <[EMAIL PROTECTED]> > > linkagent wrote: > > > I need members help on this; > > > Q1) As far as I know, \d* means match either 0 or more digits, since > > > /(\d*)/ match 1006326869812 , therefore > > > I could not see how /(\d*)(\d{4})(\d{5})/) could seperate 1006326869812 > into > > > (1006)(3268)(69812) > > > > The last two parts of the regex pick up 4 and 5 digits resp. The first > > picks up all the rest since it's 0 or more. Obviously some back-tracking > > has to occur since the first length is unknown. It might be faster to > > anchor the back end: > > /(\d*)(\d{4})(\d{5})$/ > > Correct me if I am wrong; > Therefore am I right to say that the matching sequence starts from the back > first (which is not what I read from the books about matching / /). > > i.e in the following match /(\d*)(\d{4})(\d{5})$/ > the regexes look for $ first; > then followed by (\d{5}) ; > then followed by (\d{4}) > then (\d*) > > > > Q2) Out of curiosity, I tried the undermentioned but I could not > > > understand why on the 3rd iteration it print only 3 instead of > > > 35968322963568389 :- > > > > > > for $number (1006326869812, 563296853235993 , 35968322963568389){ > > > print "$1\n" if ($number =~ /(\d*)/); > > > } > > > The third number is too large to express as an integer. > > Try putting quotes around it so it's treated as a string. > > I thought if the number is too large, it will display something like this > 3e0whatever-number, nevertheless, I will read on this. >
Which may explain why the last number matched only on the leading 3 digit. To find out for sure, the print statement could be changed to: print "$1 number=$number\n" if $number=~/(\d*)/; Actually on my PC the third number printed out as: 3.59683229635684e+016 Note that the character in the second-most significant position of the mantissa is the "." character which doesn't match the \d* regex pattern. Bill's suggestion to surround the numbers with quotes will allow the entire string of digits to match. **** [EMAIL PROTECTED] <Carl Jolley> **** All opinions are my own and not necessarily those of my employer **** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users