How to remove specials characters, but replace spaces? I have a string with spaces &amp; special characters: ABC%$! DEF*&amp; GHI
I want to remove all the specials characters, but replace the spaces with an underscore:  ABC_DEF_GHI
I have:
REGEXP_REPLACE(c.category_name, '[^\w]+','','g')

But that removes all the characters, including spaces.
Do the space-to-underscore replace() first, and your existing expression will do the rest.
testdb=# select regexp_replace(replace('ABC%$! DEF*&amp; GHI', ' ', '_'), '[^\w]+','','g');
 regexp_replace 
----------------
 ABC_DEF_GHI
(1 row)