jeudi 29 mai 2014

Regex for only Select queries?


Vote count:

0




I am looking for a regex which only allows select queries strictly, No inserts, deletes, alters or anything of that sort can be allowed and the query can have multiple lines..


I tried


var pattern="(^select)^((?!insert|delete|alter).)*$";



var pattern=^(?!insert|delete|alter|modify|add|create|drop|truncate|rename|update|rollback|commit|grant|revoke|savepoint)(.(?!insert|delete|alter|modify|add|create|drop|truncate|rename|update|rollback|commit|grant|revoke|savepoint))*$";


How to make it not match insert or any keywords on multiple lines (in javascript).


It fails in



Eg: select *
insert
into


which means it should start with "select" and cannot have insert anywhere in the query but this doesn`t work.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire