The following regex is supposed to match all js:
- conditional js (OK: already working)
- add js script (OK: already working)
- in line js (OK: already working)
- but not commented Js ( need to be implemented )
I would like to exclude all js that is commented ( but preserve the one that inside a conditional comment
Here the current regex:
^<!--(\[if lt IE.*?\])>[\s\S]*?<script(\b[^>]*?>)([\s\S]*?)<\/script>[\s\S]*?<!\[endif\]-->$|^<script(\b[^>]*?>)([\s\S]*?)<\/script>$
So skip the match for this kind of text:
<!--
<script type="text/javascript">
SOME JS
</script>
-->
OR
<!--
<script src='...' type="text/javascript"></script>
-->
Conditional comment are usually in this form:
<!--[if lt IE]>
<script type="text/javascript">
Some JS
</script>
<![endif]-->
Is it possible to do all the above in one regex ?
Since this is my first regex, if you have any other suggestion is welcome.
Thanks