'How to select and replace last occurrence of column value in postgres query

Database structure is as follow -

Table : account_name

id | string_name
1  | "110\u001F121\u001FHELLO"
2  | "110\u001F121\u001FBYE"
3  | "110\u001F122\u001FTAP"

I want to select uniq string_name from table account_name as follow expected output -

string_name
"110\u001F121\u001FNOTHING"
"110\u001F122\u001FNOTHING"

here record with id=2 cannot be selected as after adding NOTHING it will be the same as record with id=1. Also, \u001F this is a special character, it prints this character on rails console but shows blank space in pgadmin output and the format of string_name is not fixed as there may be any number of chunks connected by \u001F. We only want to replace text after last occurrence of \u001F.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source