mysql基于正则实现模糊替换字符串的方法分析
作者:Pasier 时间:2024-01-25 05:47:36
本文实例讲述了mysql基于正则实现模糊替换字符串的方法。分享给大家供大家参考,具体如下:
例如: abcd(efg)hijk 替换之后是abcdhijk
update tabaleA set name = replace(name, substring(name, locate('<contact>', name),locate('</contact>', name)-locate('<contact>'+10, name)),'');
执行之后,报错:Truncated incorrect DOUBLE value
解决办法,经过查询发现是concat(Str,'')
函数错误问题,有的DB支持+操作符,而有的就不可以必须使用concat
函数。
将SQL修改如下:
update t_global_project set name = replace(name, substring(name, locate('<contact>', name),locate('</contact>', name)-locate(concat('<contact>','10'), name)),'');
PS:这里再为大家提供2款非常方便的正则表达式工具供大家参考使用:
JavaScript正则表达式在线测试工具:
http://tools.jb51.net/regex/javascript
正则表达式在线生成工具:
http://tools.jb51.net/regex/create_reg
希望本文所述对大家MySQL数据库计有所帮助。
标签:mysql,正则,替换
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python while true实现爬虫定时任务
2021-02-10 13:35:30
批量替换sqlserver数据库挂马字段并防范sql注入攻击的代码
2024-01-28 08:03:47
详解python中静态方法staticmethod用法
2023-08-31 07:56:31
![](https://img.aspxhome.com/file/2023/3/69633_0s.png)
浅谈python中的多态
2022-09-13 16:45:40
vue+webpack模拟后台数据的示例代码
2024-06-05 10:04:11
![](https://img.aspxhome.com/file/2023/1/122001_0s.png)
关于 Web,你可能不知道的
2008-09-18 12:09:00
![](https://img.aspxhome.com/file/UploadPic/20089/18/2008918121258407s.jpg)
Python中断多重循环的几种方式详解
2022-05-09 21:44:04
用python写一个定时提醒程序的实现代码
2021-04-12 12:25:45
![](https://img.aspxhome.com/file/2023/7/114607_0s.jpg)
chatgpt国内镜像 pycharm idea插件使用详解
2022-03-29 10:08:41
![](https://img.aspxhome.com/file/2023/7/114707_0s.jpg)
python计算二维矩形IOU实例
2022-03-07 23:40:18
![](https://img.aspxhome.com/file/2023/8/95208_0s.jpg)
详解Python循环作用域与闭包
2023-01-28 20:34:30
一文带你深入了解Python中的二次移动平均法
2021-08-30 00:28:12
![](https://img.aspxhome.com/file/2023/1/101211_0s.png)
mysql 5.7.17 winx64解压版安装配置方法图文教程
2024-01-22 07:47:16
![](https://img.aspxhome.com/file/2023/0/70480_0s.png)
python整小时 整天时间戳获取算法示例
2021-02-11 10:27:33
js实现九宫格布局效果
2024-04-19 11:03:42
![](https://img.aspxhome.com/file/2023/7/136237_0s.jpg)
Python中socket网络通信是干嘛的
2023-12-16 02:57:03
Magic Photo Frame 神奇创意相框
2009-09-15 20:45:00
Oracle数据表中的死锁情况解决方法
2024-01-15 11:23:01
![](https://img.aspxhome.com/file/2023/5/65685_0s.png)
学习Python爬虫的几点建议
2023-08-08 04:29:08
python3 读取Excel表格中的数据
2021-01-14 23:03:42