Raw Input
Number 5733910 Another 1234567
Desired Output
Number 5,733,910 Another 1,234,567
Script and Comments
Script1 [sed]
[ 1] :loop
[ 2] s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/g
[ 3] t loop
Script2 [perl]
[ 1] $line = 'Number 5733910 Another 1234567';
[ 2] $line =~ s/(\d{1,3})(?=(\d{3})+(?!\d))/$1,/g;
[ 3] print "$line\n";