如何在 mysql 中编写正则表达式 lookahead/lookbehind
How to write a regex lookahead/lookbehind in mysql
我正在尝试做类似
的事情
SELECT * FROM table WHERE column REGEXP (abc)(?=def)
我得到了错误
Got error 'repetition-operator operand invalid' from regexp
由于 '?' -> 参见 #1139 - Got error 'repetition-operator operand invalid' from regexp
mysql 中是否有我在 https://dev.mysql.com/doc/refman/5.7/en/regexp.html 中没有看到的等效项?
或者我还不知道的另一个 mysql 函数?
MySQL REGEXP
不支持前瞻,但您可以尝试使用类似这样的方法实现相同的逻辑:
WHERE column LIKE 'abc%' AND
SUBSTRING(column, INSTR(column, 'abc') + 3, 3) <> 'def'
我正在尝试做类似
的事情SELECT * FROM table WHERE column REGEXP (abc)(?=def)
我得到了错误
Got error 'repetition-operator operand invalid' from regexp
由于 '?' -> 参见 #1139 - Got error 'repetition-operator operand invalid' from regexp
mysql 中是否有我在 https://dev.mysql.com/doc/refman/5.7/en/regexp.html 中没有看到的等效项?
或者我还不知道的另一个 mysql 函数?
MySQL REGEXP
不支持前瞻,但您可以尝试使用类似这样的方法实现相同的逻辑:
WHERE column LIKE 'abc%' AND
SUBSTRING(column, INSTR(column, 'abc') + 3, 3) <> 'def'