3

I have table article which contains columns like title, author, headline, body, subheading, abstract, and some more. I'm trying to replace all instances of particular symbol in all aforementioned columns at once (but not in the others) but I must say that working on SQL and databases isn't anything I know much about...

I've found this line here on stackoverflow, however after editing it into what I thought would work I see no effect. I hoped to start with just title column to see the results:

UPDATE article SET title = replace(title, '<U+2029>', ' ');

But it didn't change anything.

Can somebody explain to me what am I doing wrong and what to write in PostgreSQL to get what I need?

1

1 Answer 1

4

If that is a unicode constant, then you can try this:

UPDATE article
    SET title = regexp_replace(title, U&'\2029', ' ', 'g');

This assumes that 2029 is the hexadecimal representation of the character.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, you just saved me from manually editing a couple of thousand entries! Just one thing: it should be: ...' ', 'g');, didn't work without apostrophes around g.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.