I'd like to filter out (mostly one-line) comments from (mostly valid) JavaScript using python's re
module. For example:
// this is a comment
var x = 2 // and this is a comment too
var url = "http://www.google.com/" // and "this" too
url += 'but // this is not a comment' // however this one is
url += 'this "is not a comment' + " and ' neither is this " // only this
I'm now trying this for more than half an hour without any success. Can anyone please help me?
EDIT 1:
foo = 'http://stackoverflow.com/' // these // are // comments // too //
EDIT 2:
bar = 'http://no.comments.com/'