working-yoghurt-1995
working-yoghurt-1995

Reputation: 99

Duplicate quotes in a postgres string

I have a function that generates a new user in the database. I would like to check if the email address contains any quotes and if it does, I would like to duplicate them.

For example, I have the following email address: test.o'[email protected] and I would like to transform it into test.o''[email protected].

Could anybody help me with this? Thank you

Upvotes: 1

Views: 263

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521389

Assuming you expect only one single quote (and not double or more), you could try using a simple replace:

UPDATE yourTable
SET email = REPLACE(email, '''', '''''');

Upvotes: 2

Related Questions