Building up on this answer I thought of using PostgreSQL's regexp_replace function along with to_char to make a PHP created, SQL-fed table have a column of numbers be centralized, but right aligned.
On the HTML front, the column is already centralized, but that makes numbers with a different length to not align with each other to the right. The idea on that answer would be to make all numbers have the same length, leading with empty spaces, to make them be aligned to the right.
I got as far as trying regexp_replace(to_char(field,'FM000,000,000'),$$^(0{1,3},?)+$$,' '), but this will make EVERY 0 to the left, along with grouping ,, to be replaced by a single HTML  .
Can someone suggest a way to change every 0 into  ? I'm pretty sure the same solution can then be applied to another regexp_replace so I can replace any "left grouping ," into  .