There's a column in my database which has got this kind of value:

id|       body
1 | ... <img src=test.jpg> ... 
2 | ... <img src=test2.jpg> ... 
3 |... <img src=tests3.jpg> ....

Basically, after the = sign I can have anything. And I would like to change it for nothing.

I know if it was a static value I could use:

SELECT REPLACE(column, $$<img src=tests3.jpg>$$, ' ') FROM table

But I couldn't do it dynamically.


regexp_replace() seems ideally suited

SELECT REXEXP_REPLACE(column, $$<img src=[^>]*>$$, ' ','g') FROM table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.