For a project with many HTML files like this one:
https://ghostbin.co/paste/dngdh
I need to use vscode's regex replace to strip out the NewRelic script tag from each file that has it.
I was able accomplish this with the following regex:
<script type="text\/javascript">\n[^^]*(newrelic)[^>]*>
Essentially this works because the code between the NewRelic script tags does not contain a "^" character. I could have also gotten away with [^#]
. Also I had to play with it until I was able to encompass the closing </script>
tag, because the NewRelic script contained a "<" operator.
My question is: Could I have written a better regex? I rarely use regex and found myself crashing vscode multiple times experimenting with what I assume must have been more "greedy" patterns?
I settled on this, though it seems to be a very fragile pattern, but good enough to get the job done. However, I would like to know if there is another better pattern (that doesn't crash vscode)?
Thanks for any ideas.