return to the main page Mastering Regular Expressions
Second Edition

Listings from page 67
Download all listings shown below.

Chapter 2; page 67 (download)

$text =~ s/(\d)(?=(\d\d\d)+(?!\d))/$1,/g;

Chapter 2; page 67 (download)

$text =~ s/(\d)((\d\d\d)+\b)/$1,$2/g;

Chapter 2; page 67 (download)

undef $/;    # Enter "file-slurp" mode.
$text = <>; # Slurp up the first file given on the command line.

Copyright © 2025 Jeffrey Friedl

Fetch additional Second-Edition listings and data:

Fetch listings from page(s)