title: Remove function calls from javascript code dynamically using PHP
body: <p>I want to remove a specific function which is void (doesn't return anything) from my javascript source code using php at run time. Consider the following js code which is supposed to be outputted by php:</p>
  
  <pre><code>var a = func1(x1);
  func2(a + ": " + x1);
  // other codes
  func2(someOther("Lol") + x1);
  // other codes
  </code></pre>
  
  <p>here I want to remove <code>func2</code> (it is something like a log function which outputs something to js console). </p>
  
  <p>Now first thing that came to my mind was writing a regex and replace it with an empty string using <code>preg_replace</code>. But I wasn't successful in defining the right expression. I was wondering that is it possible to write a regex to match the function calls? If it is could you please give me some hints or examples so that I could use it? </p>
  
  <p>And if you think that there is an alternative way of doing it, I'd appreciate to hear yours.</p>
  
  <p><strong>Notes</strong></p>
  
  <ul>
  <li>The function is not used in complicated structures like <code>if</code> conditions and etc. (I mean you don't need to consider these situations)</li>
  <li>It is possible to call other functions inside this one (as arguments)</li>
  <li>I can not change js codes. (they are submitted by other people)</li>
  </ul>