How To Remove Spaces Between Characters In PostgreSQL?
simplest way - use REPLACE function

select REPLACE('NES 123_4_5', ' ', '')
Result - NES123_4_5


full list of string functions - https://www.postgresql.org/docs/9.6/static/functions-string.html