[Mastering-perl] Mastering Perl done. Done. Done. and Done.
brian d foy
brian.d.foy at gmail.com
Sat Feb 10 01:44:18 EST 2007
So, I think I've finished the book. The last hold out was a decent
example of the postive lookbehind assertion. I didn't want to steal
Jeffrey Freidl's commifying example, but I did when I discovered I
could do it under the guise of improving on it. His doesn't handle
numbers with a decimal point, and I was able to do that by shoving
three different lookarounds in there (and yes, I know about perlfaq4,
having written the answer for adding commas to numbers).
$money =~ s/
(?<!\.\d) # not a . digit right before the position
(?<=\d) # a digit right before the position
# <--- CURRENT MATCH POSITION
(?= # this group right after the position
(?:\d\d\d)+ # one or more groups of three digits
\b # word boundary (left side of decimal or end)
)
/,/xg;
I also added some figures to the discussion of lookarounds, which
makes everything much easier to see.
So now the book goes to QC1, where the O'Reilly people try to make it
into a book, and hopefully take a long time to do it so I can take a
break.
Well, I'm not really taking a break because Randal and I started on
"Learning Perl 6" last week. We don't have anything to show yet, but
eventually it will be at http://www.learningperl6,com, which looks
remarkably like my Mastering Perl site.
--
brian d foy <brian.d.foy at gmail.com>
http://www.pair.com/~comdog/
More information about the Mastering-perl
mailing list