void () { String s1 = """ class X {{ try { conn = 1; } finally { conn.close(); } try { conn = 1; } finally { int a = 1; } try { conn = 1; } finally { int a = 1; } }}"""; String s2 = "try { '_StatementBefore*; '_Dcl:[regex( conn = 1 )]; '_StatementAfter*; } finally { '_Finally*:[!regex( .*conn.* ) ]; }"; assertEquals("FindTryWithoutProperFinally", 2, findMatchesCount(s1,s2)); }