<p>I am trying to do a search in my Eclipse (Java) workspace to find all instances of static variables that are not final.</p>

<p>I tried various regexes but they do not result in any matches. Can someone suggest a regex that will match all lines containing <code>static</code> and not containing <code>final</code>, and not ending in a <code>{</code>?</p>

<p>The last part about not ending with a <code>{</code> will eliminate static methods.</p>

<p>An example:</p>

<pre><code>public class FlagOffendingStatics {
  private static String shouldBeFlagged = "not ok";
  private static final String ok = "this is fine";
  public static void methodsAreOK() {

  }
}
</code></pre>

Eclipse should have some sort of Java search built-in where you could specify that... Else, instead of writing one large monster regexp, try chaining together a bunch of greps:
```
grep -r static . | grep -v final
```
in the 1st statement, the -r causes the grep to recurse over a directory tree starting at the local directory, the results get piped to the 2nd grep which removes all the
```
final
```
's. Keep adding -v until everything superfluous is removed from the results. This is usually easier --albeit less elegant-- than figuring out a complicated regexp to take care of everything.