I have a pattern like –
public static void myMethod(int Val , String Val){}
so public\static\void\myMethod(int\sVal\s,\sString\sVal)
but if my method have more space than one like public static it fails.
So how to make a concrete pattern .
Moreover the part inside the bracket is not working, suggest me the way to resolve.
Use
\s+to match one or more occurrence, and\s*to match zero or more occurrences. Escape the parentheses so that they are not interpreted as grouping operators.That said, it looks like you are trying to parse Java code with a regular expression. This is not possible since Java (like the infamous [X]HTML) is not a regular language.