replace single char for string using regexp_replace

From: PegoraroF10 <marcos(at)f10(dot)com(dot)br>
To: pgsql-general(at)postgresql(dot)org
Subject: replace single char for string using regexp_replace
Date: 2019-12-30 00:00:59
Message-ID: 1577664059509-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have to replace ; , " and ' chars in an string putting its correspondent
ascii value

I have a
Replace(Replace(Replace(Replace($$Text,with;On'It"$$,',','chr(59)'),';','chr(44)'),'"','chr(34)'),'''','chr(39)')
It works but I would like to call just one Replace.

I tried this but didn´t work
select
regexp_replace($$Text,with;On'It"$$,$$,|;|"|'$$,$$chr(59)|chr(44)|chr(34)|chr(39)$$,'g');
, -> chr(59)
; -> chr(44)
" -> chr(34)
' -> chr (39)

--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-12-30 04:50:03 Re: replace single char for string using regexp_replace
Previous Message Jeff Janes 2019-12-29 22:27:10 Re: Are my autovacuum settings too aggressive for this table?