I am cleaning up / priming our PostgreSQL 12 database for future data-related activities (e.g. data encryption). I have tried the following methods to delete non-basic Latin / basic accented Latin / punctuational values from one of our tables:
regexp_replace(field, '[^[:graph:]]', '', 'g')
andSIMILAR TO '%[^[:graph:]]%'
(in our implementation,[:print:]
is not working inregexp_replace
)btrim(field, '')
- not working for Unicode character-containing strings but only Latin strings.
However, the extraneous Unicode characters, even those embedded within acceptable (i.e., Latin and punctuational) values (e.g. \ud83d
) do not get filtered / deleted from the values, hence, I couldn't prime the data.
What can I do to filter out only unacceptable Unicode values in regexp_replace
and delete them, retaining only acceptable characters?
[:graph:]
or[:print:]
character classes. Please define acceptable characters exactly. The underlying OS andLC_CTYPE
also influence character classes beyond the the 7-bit ASCII set.