title: PHP preg_replace for anything on a line that starts with //
body: <p>I am trying to remove single line comments from a js file. Of course, all of the lines will look something like:</p>
  
  <pre><code>// This is a comment in a js file
  </code></pre>
  
  <p>What is the regex to remove everything on a line that begins with <code>//</code>?</p>
  
  <p>I'm already using this to remove multi line comments:</p>
  
  <pre><code>/* This is a
     multi-line comment */
  
  $js = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $js_contents);
  </code></pre>
  
  <p>Thanks!</p>