I have the following regex:
(?i:outer|inner ){0,1}(?i:JOIN (tableC|tableG) AS )([a-zA-Z0-9\r\n ~()=<>#_'"-])*(?=(?i:JOIN|WHERE))
I am testing this against this SELECT statement:
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
Now, I want the regex to match INNER JOIN tableC AS C ON B.fieldC = C.fieldC INNER
. However, it matches until the first occurrence of WHERE.
INNER JOIN tableC AS C ON B.fieldC = C.fieldC INNER JOIN tableD AS D on C.fieldD = D.fieldD
I am quite confused as I clearly stated in the regex to positively lookahead for a WHERE or a JOIN. However, it seems to be looking up until the last occurrence of any of these alternatives? Can anyone give insight on what's wrong and why is this happening to my regex?
Thanks!