私のJavaファイルには、次のようなJava文字列に割り当てられた多くのSQLクエリがあります。
/* ... */
String str1 = "SELECT item1, item2 from table1 where this=that and MYWORD=that2 and this3=that3";
/* ... */
String str2 = "SELECT item1, item2 from table1 where this=that and" +
" MYWORD=that2 and this3=that3 and this4=that4";
/* ... */
/* ... */
String str3 = "SELECT item1, item2 from table2 where this=that and this2=that2 and" +
" this3=that3 and this4=that4";
/* ... */
String str4 = "SELECT item1, item2 from table3 where this=that and MYWORD=that2" +
" and this3=that3 and this4=that4";
/* ... */
String str5 = "SELECT item1, item2 from table4 where this=that and this2=that2 and this3=that3";
/* ... */
ここで、「MYWORD」という単語を含まない「SELECT ...」クエリを見つけたいと思います。
以前の S/O の質問の 1 つから、すべての ' SELECT...
' クエリを見つける方法の答えを得ましたが、その解決策を拡張して、特定の単語を含まないものを見つける必要があります。
SELECT(?!.*MYWORD).*;
複数行のクエリ(上記のstr3など)を見つけることができず、単一行のクエリのみを見つける正規表現を試しました。
また、すべてのクエリを検索する正規表現を試しましたSELECT[\s\S]*?(?!MYWORD).*(?<=;)$
が、クエリに「MYWORD」という単語が存在するかどうかを判断できません。
私は解決策に非常に近いことを知っていますが、まだそれを理解することはできません. 誰でも私を助けてもらえますか?(Windowsでメモ帳++を使用しています)