如何在mysql中编写正则表达式lookahead/lookbehind

gui*_*our 6 regex mysql lookahead

我正在尝试做类似的事情

SELECT * FROM table WHERE column REGEXP (abc)(?=def)
Run Code Online (Sandbox Code Playgroud)

我收到了错误

Got error 'repetition-operator operand invalid' from regexp
Run Code Online (Sandbox Code Playgroud)

因为 '?' - >参见#1139 - 从regexp获得错误'重复 - 操作数操作数无效'

我在https://dev.mysql.com/doc/refman/5.7/en/regexp.html中没有看到mysql中的等价物吗?

或者可能是另一个我还不知道的mysql函数?

Tim*_*sen 2

MySQLREGEXP不支持前瞻,但您可以尝试使用类似以下的方法来实现相同的逻辑:

WHERE column LIKE 'abc%' AND
      SUBSTRING(column, INSTR(column, 'abc') + 3, 3) <> 'def'
Run Code Online (Sandbox Code Playgroud)