gpt4 book ai didi

php - mysql 替换困难条件

转载 作者:行者123 更新时间:2023-11-29 23:42:00 24 4
gpt4 key购买 nike

a 在 db.table 中有 2 行:

+79513028643+text@example.com
marin.nikulina2014+text@example.com

我需要替换这些电子邮件地址

+79513028643@example.com
marin.nikulina2014@example.com

我提出了这样的要求

update voters set email = concat( replace( substring_index(email, '@', 1), substring_index(substring(email, 2), '@', 1), substring_index(substring(email, 2), '+', 1) ),'@', substring_index(email, '@', -1)) WHERE voters.key regexp 'a78605bb9b9c5512ab3f7a06f73124ffcdafdddf|32a08a88001074fb59db19a3c3a83eb89f75a052'

执行后

+79513028643@example.com@example.com
marin.nikulina2014@example.com

看看第一个地址发生了什么请大家帮忙查询一下!谢谢!

更新一些电子邮件地址不包含符号“+”upd(2) 符号“+”之后的文本可能不同

最佳答案

试试这个:

UPDATE  mytable
SET email = REPLACE(email, '+text', '')
WHERE email REGEXP '+79513028643+text@example.com'

或者您可以使用其中之一:

REGEXP_LIKE(text, pattern [, mode])
REGEXP_SUBSTR(text, pattern [,position [,occurence [,mode]]])
REGEXP_INSTR?(text, pattern [,position [,occurence [,return_end [,mode]]]])
REGEXP_REPLACE?(text, pattern, replace [,position [,occurence [,return_end [,mode]]])

关于php - mysql 替换困难条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26119200/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com