select replace(fieldname,',','')::numeric ;
To do this the way you originally tried, which is not recommended:
select to_number( fieldname, regexp_replace( replace(fieldname,',','G') , '[0-9]' ,'9','g') );
Internal replacement replaces commas with G An external replacement changes the numbers to 9 . This does not include decimal or negative numbers.
source share