in reply to Regexp doubts
or$_ = reverse(join(',', reverse($_) =~ /.{1,3}/g));
or$_ = join(',', split(/(?<=.)(?=(?:.{3})+\z)/, $_));
$_ =~ s/(?<=.)(?=(?:.{3})+\z)/,/g;
Update: Tested. Fixed. I knew I needed that \z.
Update: Added third solution, a simplification of the second.
|
|---|