How to write a regex lookahead/lookbehind in mysql

后端 未结 1 381
谎友^
谎友^ 2021-01-05 11:18

I\'m trying to do something like

SELECT * FROM table WHERE column REGEXP (abc)(?=def)

and I got the error

Got error \'rep         


        
相关标签:
1条回答
  • 2021-01-05 12:14

    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'
    
    0 讨论(0)
提交回复
热议问题