Regex is capturing the whole string
- by M28
I am using the following regex:
(public|private +)?function +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)}
To match the following string:
public function messenger(text){
sendMsg(text);
}
private function sendMsg(text){
alert(text);
}
(There is no line breaks in the string, they are converted to whitespaces before the regex runs)
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); "
By the way, I am using Javascript.