SoFunction
Updated on 2025-04-06

Delete regular expressions of comment statements in javascript


function removeJsComments(code)  
{    
    return (/(?:^|\n|\r)\s*\/\*[\s\S]*?\*\/\s*(?:\r|\n|$)/g, '\n').replace(/(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/g, '\n'); 
}