我有以下正则表达式:
(?i:outer|inner ){0,1}(?i:JOIN (tableC|tableG) AS )([a-zA-Z0-9\r\n ~()=<>#_'"-])*(?=(?i:JOIN|WHERE))
我正在对这个SELECT语句进行测试:
SELECT columnA FROM tableB AS B
INNER JOIN tableC AS C ON B.fieldC = C.fieldC
INNER JOIN tableD AS D on C.fieldD = D.fieldD
WHERE D.fieldE = C.fieldE
现在,我希望正则表达式匹配INNER JOIN tableC AS C ON B.fieldC = C.fieldC INNER
。但是,它匹配直到第一次出现WHERE。
INNER JOIN tableC AS C ON B.fieldC = C.fieldC INNER JOIN tableD AS D on C.fieldD = D.fieldD
我很困惑,因为我在正则表达式中明确指出要积极地预测WHERE或JOIN。但是,它似乎一直在查找,直到最后一次出现这些替代方案?任何人都可以提供有关错误的见解以及为什么这会发生在我的正则表达式中?
谢谢!