This model works:
[^(final)] static [^(final)][^(\})]*$
Here is the test:
$ cat test.txt private int x = "3"; private static x = "3"; private final static String x = "3"; private static final String x = "3"; private static String x = "3"; public static void main(String args[]) { blah; } $ grep "[^(final)] static [^(final)][^(\})]*$" test.txt private static x = "3"; private static String x = "3";
(I understand that private static x = "3"; is not valid syntax, but the template is still saved.)
The sample takes into account the fact that final can appear before or after static with [^(final)] static [^(final)] . The rest of the pattern [^(\})]*$ intended to prevent any { characters from appearing in the rest of the string.
This template will not work if someone likes to write their instructions like this:
private static void blah() {
matt b
source share