mysql - 正则表达式示例与官方文档结果不匹配
问题描述
来自 MySQL 文档:
https://dev.mysql.com/doc/refman/8.0/en/regexp.html(MySQL 8.0):
mysql> SELECT 'new*\n*line' REGEXP 'new\\*.\\*line';
+---------------------------------------+
| 'new*\n*line' REGEXP 'new\\*.\\*line' |
+---------------------------------------+
| 0 |
+---------------------------------------+
和https://dev.mysql.com/doc/refman/5.7/en/regexp.html(MySQL 5.7):
mysql> SELECT 'new*\n*line' REGEXP 'new\\*.\\*line';
+---------------------------------------+
| 'new*\n*line' REGEXP 'new\\*.\\*line' |
+---------------------------------------+
| 0 |
+---------------------------------------+
但是为什么我1
在 MySQL 5.7 和0
MySQL 5.8 中有?
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2212
Server version: 5.7.33-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT 'new*\n*line' REGEXP 'new\\*.\\*line';
+---------------------------------------+
| 'new*\n*line' REGEXP 'new\\*.\\*line' |
+---------------------------------------+
| 1 |
+---------------------------------------+
1 row in set (0.00 sec)
mysql>
===========
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1107
Server version: 8.0.23 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> SELECT 'new*\n*line' REGEXP 'new\\*.\\*line';
+---------------------------------------+
| 'new*\n*line' REGEXP 'new\\*.\\*line' |
+---------------------------------------+
| 0 |
+---------------------------------------+
1 row in set (0.00 sec)
mysql>
我很困惑。哪个应该是正确的?至于我,我认为它匹配..
解决方案
推荐阅读
- r - 如何使用 R 在另一个特定模式之前提取两个特定模式?
- sql - 在建模数据库结构(SQL 或 Django)方面需要帮助
- c# - 如何反序列化 json 配置中不同对象类型的列表?
- amazon-web-services - Kuberentes AWS 云提供商
- javascript - 如何在 vue JS 2 的数组中更新或添加对象?
- typescript - 使用可选链接时,“对象”类型上不存在属性
- amazon-web-services - 如何使用 AWS API Gateway UI 覆盖路由上的路径以发送到相同的集成
- amazon-web-services - 来自 AWS RDS 的数据是否存储在 Amazon S3 上?
- scala - 使用类型构造函数定义函数签名以禁止某些数据类型
- sql - 如何将 Raspberry Pi SenseHat 数据导入 azure sql server