regex - how to replace strings in postgresql by using regular expression? -


t.emailaddresses contains comma separated email addresses.

i want replace email address '0', how can regular expression ?

i wrote replace(), want write in regex wayemailaddresses

select t.emailaddresses,        replace (replace (replace (replace (t.emailaddresses,          'jack@example.com', '0'), 'jack@mybox.com', '0'), 'emly@example.com',          '0'), 'emly@mybox.com', '0') replaced_email_address table t t.id = 100; 

thanks in advance!!!

the general regex syntax replacing be:

select regexp_replace(mycolumn, $rxb$^jack@example\.com$$rxb$, $$0$$, 'g') mytable; 

but...

  • if you're replacing literal (something doesn't change, there's no point.
  • it's useful if want maybe replace email starts jack

for example,

select regexp_replace(mycolumn, $$^jack.*$$, $$0$$, 'g') mytable; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -