RE: sprintf question

2001-11-28 Thread Jeffrey
--- "Keith C. Ivey" <[EMAIL PROTECTED]> wrote: > The next character after \d+ isn't necessarily a > nondigit. It > depends on what else is in the regex and what's in > the string. > For example /\d+.$/ and /\d+\D$/ don't match the > same strings. > The first one matches "234" (with '\d+' matchin

RE: sprintf question

2001-11-28 Thread Keith C. Ivey
Carl Jolley <[EMAIL PROTECTED]> wrote: > Additionally, I believe that the sprintf format should be > "%03d". Either "%.3d" or "%03d" will work. Some people prefer the . to the 0 because it's standard C as well as Perl and because the leading 0 can imply octal rather than decimal. You can read

RE: sprintf question

2001-11-28 Thread Keith C. Ivey
Jeffrey <[EMAIL PROTECTED]> wrote: > But if you match all digits (\d+) then you are > guaranteed that the next character (if any) is a > non-digit. So if another character is required for > the regex (say, you want to match "234foo" but not > "234") then you could use a . and it wouldn't hurt th

RE: sprintf question

2001-11-27 Thread Jeffrey
I guess I should have asked Scott the following question. What's up with this regex? Particulary this part (at the end): (\d+)\D.+$ If I'm not mistaken, this piece says match all digits and capture them into $1. Match one non-digit, then anything until the end of the string. The all digits thi

RE: sprintf question

2001-11-27 Thread Troy Sniff
Ah yeah ... I didn't look at the code enough ... Sometimes I think way too fast ... > -Original Message- > From: $Bill Luebkert [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 27, 2001 2:30 PM > To: Troy Sniff > Cc: [EMAIL PROTECTED] > Subject: Re: sprint

RE: sprintf question

2001-11-27 Thread Rubinow, Larry
Jeffrey wrote: > --- "Rubinow, Larry" <[EMAIL PROTECTED]> > > You're focussing on the wrong problem. Why suck up > > all five digits in your > > regex, if you only want the first three? > > > > $str =~ /^\d+\_(\d{1,3})\d*?\D.+$/; > > So just for my clarification, is there an advantage to >

RE: sprintf question

2001-11-27 Thread Jeffrey
uot;\n"; > } > __DATA__ > 12345 > 1 > ^--Script ends here > > Output: > 123 > 001 > > Wags ;} > > -Original Message- > From: Purcell, Scott [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 27, 2001 13:09 > To: '[EMAIL PROTECTE

Re: sprintf question

2001-11-27 Thread $Bill Luebkert
Troy Sniff wrote: > Try: > > $tmp = sprintf("%03d", $tmp); I think you didn't test that. :) -- ,-/- __ _ _ $Bill Luebkert ICQ=14439852 (_/ / )// // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site f