title: Regex is capturing the whole string
body: <p>I am using the following regex:</p>
  
  <pre><code>(public|private +)?function +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)}
  </code></pre>
  
  <p>To match the following string:</p>
  
  <pre><code>public function messenger(text){
  sendMsg(text);
  }
  private function sendMsg(text){
  alert(text);
  }
  </code></pre>
  
  <p>(There is no line breaks in the string, they are converted to whitespaces before the regex runs)</p>
  
  <p>I wanted it to capture both functions, but it is capturing:
  $1: ""
  $2: "messenger"
  $3: "text"
  $4: " sendMsg(text);  }  private function sendMsg(text){   alert(text);  "</p>
  
  <p>By the way, I am using Javascript.</p>