如何在mysql中编写正则表达式前瞻/后视 [英] How to write a regex lookahead/lookbehind in mysql
本文介绍了如何在mysql中编写正则表达式前瞻/后视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试做
SELECT * FROM table WHERE column REGEXP (abc)(?=def)
我得到了错误
Got error 'repetition-operator operand invalid' from regexp
由于?" ->参见#1139-出现了错误'repetition-operator操作数无效"来自regexp
在 https://dev.mysql.com/doc/refman/5.7/zh-CN/regexp.html 吗?
还是我不知道的另一个mysql函数?
or maybe another mysql function that I don't know yet?
推荐答案
MySQL REGEXP
不支持先行,但是您可以尝试使用类似的方法实现相同的逻辑:
MySQL REGEXP
does not support lookaheads, but you can try to achieve the same logic using something like this:
WHERE column LIKE 'abc%' AND
SUBSTRING(column, INSTR(column, 'abc') + 3, 3) <> 'def'
这篇关于如何在mysql中编写正则表达式前瞻/后视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文