i`m trying find an regular expression for java that match all select statement queries that is not preceding by some keyword like insert,update,delete,procedure,etc:
At moment at got this:
^(?!insert|delete|update|procedure) {0,}select.*?;$ gims
but not matches right if select starts in new line :
Test cases:
select 1 from dual;
delete from table where id =
(
select 1 from dual
);
update table set id = 1 where id in (
select 1 from dual);
procedure dsdsd select fdsfds;
PROCEDURE myproc ()
IS
BEGIN
SELECT
1 from dual;
END myproc ;
Result : matches only select 1 from dual;
this link has test case :