title: Regex to match a Java method signature
body: <p>I am having this particular requirement where a method has to be identified by different regular expressions for different components. For example, there need to be a regex for return parameter, one for method name, one for argument type and one for argument name. I was able to come up with an expression till this step as follows -</p>
  
  <pre><code>([^,]+) ([^,]+)\((([^,]+) ([^,]+))\)
  </code></pre>
  
  <p>It works well for a method signature like -</p>
  
  <blockquote>
    <p>ReturnType foo(Arg parameter)
    The regular expression identifies ReturnType, foo, Arg and parameter separately.</p>
  </blockquote>
  
  <p>Now the problem is that a method can have no/one/multiple arguments separated by commas. I am not able to get a repeating expression for this. Help will be appreciated.</p>