我已创建移动短信应用
用户可以通过短信在他/她的手机上收到消息。
我的数据库中有5000封邮件。但有些消息有联系号码
见以下消息:
Success Is Not Permanent & Failure Is Not Final. So,
Never Stop Working After Success & Never Stop Trying After Failure...
1234567890
OR
Success Is Not Permanent & Failure Is Not Final.
01234567890
So, Never Stop Working After Success & Never Stop Trying After Failure...
OR
+911234567890 Success Is Not Permanent & Failure Is Not Final. So,
Never Stop Working After Success & Never Stop Trying After Failure...
我希望{3}格式的remove
或get
联系电话1234567890
01234567890
+911234567890
答案 0 :(得分:2)
如果这是一次性程序,则运行查询(伪代码)
SELECT id,message FROM messages
while query $row
$regex = '/\+?\d{9,13}/';
$insertString = preg_replace($regex,'',$row['message']);
UPDATE Messages
SET message = $insertString
WHERE id = $row['id']
LIMIT 1;
end while
显然这不会起作用,但它为您提供了完成任务所需的代码结构和正则表达式。
LIMIT 1
很重要!
在执行此操作之前,请不要忘记备份数据库!
答案 1 :(得分:0)
似乎它总是消息的最后一行,所以只需删除最后一行。