Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Easy C-style comment remove</title>
  <style>
    body{
      text-align: center;
      font-family: courier, monospace, helvetica, san-serif;
    }
  </style>
</head>
<body>
  <h1>Easy C-style comment remove</h1>
  <textarea id="code" style="width: 100%; height: 100%; min-height: 500px;"></textarea>
  <input type="button" value="Clean Comments" onClick="clean();">
</body>
</html>
 
function clean(){
  var str = document.getElementById("code").value;
  document.getElementById("code").value = removeComments(str);
}
function removeComments(str) {
  
    return (
        str
 
        /*
        Remove single and multi-line comments,
        no consideration of inner-contents
       */
      .replace(/^[http:]\/\/.+?(?=\n|\r|$)|\/\*[\s\S]+?\*\//g, '')
      
      .replace(/[^:]\/\/[\s\S]+?(?=\n|\r|$)/g, '')
    );
 
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x