I have the following input:
<script src="common/scripts/vendor.0.js"></script>
<script src="common/scripts/all.0.js"></script>
<script src="common/scripts/config.js"></script>
I'm trying to write a Grunt task to do a match/replace with JavaScript regex to something like this:
{
match: /<(script.*?src=)"(.*?)"(.*?)>/g,
replacement: '<$1"//<%= config.cdn.preview[0] %>/$2"$3>'
}
And I get this output:
<script src="//cdn.domain.com/common/scripts/vendor.0.js"></script>
<script src="//cdn.domain.com/common/scripts/all.0.js"></script>
<script src="//cdn.domain.com/common/scripts/config.js"></script>
So far so good... The only thing is... I don't want to do the match/replace the line with the config.js
file, only the other two. I want the output to be this:
<script src="//cdn.domain.com/common/scripts/vendor.0.js"></script>
<script src="//cdn.domain.com/common/scripts/all.0.js"></script>
<script src="common/scripts/config.js"></script>
I've tried countless things I found here on SO and Google but can't seem to find a solution for this.