title: How to remove JS comments using PHP?
body: <p>How to remove JS comments using PHP?
  This question is updated: Nov. 4 2013 and answered by: Alexander Yancharuk
  But there is a problem right now. A new code: <code>id = id.replace(/\//g,'');</code></p>
  
  <p>This is my example:</p>
  
  <pre><code>&lt;?php
  $output = "
  //remove comment
  this1 //remove comment
  this2 /* remove comment */
  this3 /* remove
  comment */
  this4 /* * * remove
  * * * *
  comment * * */
  this5 http://removecomment.com
  id = id.replace(/\//g,''); //do not remove the regex //
  ";
  
  $output = preg_replace( "/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?&lt;!\:)\/\/.*))/", "", $output ); //Yancharuk's code/regex
  // "/(?&lt;!\:)\/\/(.*)\\n/ = my oldest code
  
  echo nl2br($output);
  ?&gt;
  </code></pre>
  
  <p>My Problems;</p>
  
  <ol>
  <li>Something wrong with the this1 line;</li>
  <li>The //comments is working but I can't create a codes to remove /*
  comment */  or by that comment with a line break</li>
  </ol>
  
  <p>Here is the output, recent:</p>
  
  <p><br />
  <br />
  this1 <br />
  this2 <br />
  this3 <br />
  this4 <br />
  this5 <a href="http://removecomment.com">http://removecomment.com</a><br />
  id = id.replace(/\</p>