I'm trying to remove all comments from an javascript-file. So I need to remove all /* ... */ an // ...
That's not a big problem. My Problem is that it is possible that these things can also stand inside strings.
So let me give you some samples:
Code: Select all
xxxx //commentCode: Select all
xxxx /* comment
comment */
Code: Select all
var = 'xxx //nocomment'; //commentCode: Select all
var = 'xxx /* nocomment'; /*comment*/I started to create a regex for this:
Code: Select all
/(?<!')\/\/.*/Code: Select all
/(?<!('|"))\/\*.+\*\//I hope you understand what i'm trying to do and anyone can help me with this.
Thanks!