How can I with regex find string “executeQuery” but not if whole string has “vo” or “Viewobject”.
Examples:
ResultSet rs = ps.executeQuery(); --> CORRECT
super.executeQueryForCollection(object, object1, i); --> CORRECT
voOEPoDEStruktura.executeQuery(); --> WRONG
ViewObject.executeQuery(); --> WRONG
^(?!.*(?:vo|ViewObject)).*executeQuery.*is the regex which will match the specifications. I didn’t use capturing groups because you didnt specify that you want to capture anything.You should use the solution with contains because it’s easier to understand.