skip to Main Content

I am having werid problem. Trying to remove whitespace characters from varchar variable in PostgresSQL. However one space is not removed. I dont know how is this possible.

Variable value: Snímek obrazovky 2019-12-05 v 13.33.37.png

regexp_replace(variable, 's', '_', 'g')

Returns: Snímek_obrazovky_2019-12-05_v 13.33.37.png (notice a space after _v)

replace(variable, ' ', '_')

Returns: Snímek_obrazovky_2019-12-05_v 13.33.37.png = the same.

I dont know what else to try. Any ides? Might be some special character in there? Can identify which kind.

2

Answers


  1. Chosen as BEST ANSWER
    replace(variable,chr(160),'_')
    

    Is the way to go.


  2. In UTF8 encoding you can check the codes of all characters in the string:

    select ch, ascii(ch) as code
    from unnest(regexp_split_to_array('Snímek obrazovky 2019-12-05 v 13.33.37.png', '')) as ch
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search