I need a regular expression that works to remove comments from HTML, JS and CSS.
The biggest problem I find is in the line comments. As in the project where I work there is a lot of JS to fire in HTML, if I try to detect // until end of line, also matchea urls.
Even so, I solved it with this:
/((?<!(\:))(\/\/)(.|\s)*?(\n))/g
But it's not enough, since there can be a type% ur_of% and it's loaded too.
With this I solved it:
/(?<=\")((?<!(\:))(\/\/)(.|\s)*?(\n))(?=\")/g
But now I am faced with the problem that sometimes (for reasons I do not know) there may be something in front of those two bars. Ex: src="//jquery.etc"
How can I directly detect if it's encapsulated so it does not get deleted?
Thanks in advance.