0

I have some sql select queries and I want to extract all those statements wherein a given set of columns (say A,B,C) is being selected from a given table (say X). The regex should be able to match

select A,B,C,D,E from X,Y,Z,(select * from R)
select B,C,A from Y,X

I tried something like this:

select(?=.*\sA)(?=.*\sB)(?=.*\sC).*\sfrom(?=.*\sX).*

but it also matches scenarios like

select D from X,(select A,B,C) from Z

1 Answer 1

0

Something like this should work

select [ABCD,]{3,} from X.*

Assuming that you want to select statements which are selecting more then 2 coloumns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.