postgres=# -- trim([both] bytes from string)
postgres=# -- Remove the longest string containing only the bytes in bytes from the start and end
postgres=# -- of string
postgres=#
postgres=# select trim('\\001'::bytea from '\\001Tom\\001'::bytea);
btrim
-------
Tom
(1 row)
postgres=#
postgres=#