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
  • 90,351
  • 20
  • 107
  • 135
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
  • 10,015
  • 8
  • 46
  • 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
  • 24,276
  • 16
  • 82
  • 119