gpt4 book ai didi

mysql - 正则表达式无效字符长度

转载 作者:行者123 更新时间:2023-12-01 00:16:57 26 4
gpt4 key购买 nike

这个 MySQL 查询有效:

SELECT p.slug FROM products AS p
WHERE p.slug REGEXP '[^a-zA-Z0-9_-]'

但是这个不行:

SELECT p.slug FROM products AS p
WHERE p.slug REGEXP '[^a-zA-Z0-9_-(]'

这两个都不行:

SELECT p.slug FROM products AS p
WHERE p.slug REGEXP '[^a-zA-Z0-9_-\(]'

最佳答案

你需要使用 \\ 来转义那个特殊字符

SELECT p.slug FROM products AS p WHERE p.slug REGEXP '[^a-zA-Z0-9_-\\(]'

引用请阅读 doc

EDIT: use \\ to escape any special character in your expression. like in above query - is special character.

关于mysql - 正则表达式无效字符长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57788719/

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