Regular expression to identify java function I am trying to identify a java function block addition  in a diff file (new line start with + in diff).
For that I am using regular expression.

It is working fine, however I need to identify all (if not, at least maximum) possible combinations of keyword used in java method declarations.

Here is my regular expression written in my java program

Pattern functionPatter = Pattern.compile("\\+\\s*(public|private|protected)?(\\s+static)?(\\s+final)?\\s+\\w+\\s+\\w+\\s*\\(.*?\\)\\s*(throws .*)+\\{.*\\}",Pattern.DOTALL); 


Please suggest me if I am missing anything.
I have no idea what you are trying to match with \\s+\\w+\\s+\\w+\\s*.  If you are looking for a return type, then that won't do at all.

It appears that you are trying to match the function body using \\{.*\\}.  That won't work, because braces may be nested, and regular expressions cannot handle nesting.

Modifier keywords can appear in any order, and you are missing a few, such as:


synchronized
transient
volatile
strictfp


If you want to implement this correctly, don't just make assumptions based on code that you have been seeing.  Read the Java Language Specification.