Javascript regex for known script tag combinations -


another regex question, yes, context implementation within grunt process, known set of files iterate , in files known combinations of script tags. there 0 chance of user interference, , target files not change on time.

here combinations want catch in single regex:

<script>*</script> <script type="text/javascript">*</script> 

edit: above combo should exclude:

<script src=""></script> <script src="" type="text/javascript"></script> <script src=""></script> <script src="" type="text/javascript"></script> 

and need second regex catch following:

<!--[if lt ie 9]><script>*</script><![endif]--> 

and third regex catch following:

<!--[if lte ie 9]><script>*</script><![endif]--> 

please don't combine regexes, need different outcomes each.

for reference, i've worked way through answer q/a: removing script tags html js regular expression

but catch much, , none of suggestions there cater separate regex conditional ie comments need treat separately.

also, have tried grunt-dom-munger, there many undesirable outcomes, , trying simplified solution involving regex actions separate outcomes, within grunt-text-replace.

many clever, clever regex folk!

first regex:

<script(?: type.*)?>.*<\/script> 

second regex:

<!--\[if lt ie 9\]><script>.*<\/script><!\[endif\]--> 

third regex:

<!--\[if lte ie 9\]><script>.*<\/script><!\[endif\]--> 

regex matches both second , third:

<!--\[if lte? ie 9\]><script>.*<\/script><!\[endif\]--> 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -