I am struggling with a regex in php to extract function arguments from a string. I am parsing a javascript file in php and want to extract 2 function arguments from a line. Here is an example of how the lines may look:
"Backbone.Radio( 'comments ').trigger("added:comment " ,function(){});"
From this line I want to extract the word comments and added:comment without any whitespaces or quotes.
I have tried with:
$arrMatches = array();
$strRegEx = "/\\(\\s*['\"]\\s*([^)]+?)\\s*['\"]\\s*/";
$nMatches = preg_match_all($strRegEx, $strLine, $arrMatches);
But this will give me something like: ( 'comments ' and ("added:comment "
I would appreciate some help with how to solve this.
(and'and"after you've gotten your results? Or will this method affect it, as the comments itself may contain brackets?