mariadb - MariaDB regexp_replace 反向引用未按预期工作
问题描述
我在用户定义的函数中有这个简单的正则表达式
set mm = regexp_replace(in_str, '^M([0-9]+(\.[0-9]+)?).*$', '\\1');
在 MariaDB 10.1 中传入“M56-5”时,我会按预期得到“56”,但在 MariaDB 10.4 中,我收到错误“第 1 行的列 'mm' 的数据被截断”。当我传入“M56.5”时,我在两个版本中都按预期得到了“56.5”。有什么改变吗?
解决方案
I figured it out. I mistakenly was using a single backslash to escape the "." whereas it is required to use 2 backslashes when escaping special characters, one for the MariaDB parser and one for the regex library. https://mariadb.com/kb/en/regular-expressions-overview/#escaping
推荐阅读
- python - 如何从存储在元组列表列表中的两个元素元组中创建两个列表
- javascript - 如何在此弹出窗口上获取/查看选定的文本,?所以这可以看出将要分享什么文本
- swift - 我正在尝试更改搜索控制器搜索栏文本字段的占位符文本颜色
- reactjs - 我应该将我的 node_modules 文件夹签入我的代码存储库吗?
- flutter - 如何从一个飞镖文件访问另一个方法?
- java - Spring Security:如何在注销时撤销刷新令牌?
- python - PyQt5中奇怪显示的图像加载
- python-3.x - 在列表中分组相似的月份和年份
- java - 如何在 Java 中使用 Base64 进行哈希加密和解密
- abap - SAP Gateway - XML-ABAP 转换的意外文本