0

I'm trying to change a number of domain names in email addresses in a mySQL table such as

name@old.domain.co.uk to something like name@newdomain.com

Can I use a Regular Expression to do this in an update statement and if so how would I go about this?

stema
  • 85,585
  • 19
  • 101
  • 125
Wheelz
  • 219
  • 1
  • 2
  • 9

2 Answers2

1

There's no regex replace in MySQL but you can use an UDF (User defined function) like these:

Links extracted from the answers here

Community
  • 1
  • 1
SERPRO
  • 9,867
  • 7
  • 44
  • 63
0

No, sorry MySQL regex functionality is limited to just searching, you can't directly replace with it.

Using a UDF to give regex functionality works though, if you want to go that route -

http://www.mysqludf.org/lib_mysqludf_preg/

https://launchpad.net/mysql-udf-regexp

Community
  • 1
  • 1
Michael Low
  • 23,771
  • 15
  • 77
  • 117