Regex search-and-replace to add script elements to a lot of html files

I needed to add a script tag in every file that included jquery.ui.core.js, directly after that that existing element, with the same indentation. This is what worked quite nicely for me:

Search for: (\s+)<script type=”text/javascript” src=”(.+)/ui/jquery.ui.core.js”></script>

Replace with: $1<script type=”text/javascript” src=”$2/ui/jquery.ui.core.js”></script>$1<script type=”text/javascript” src=”$2/ui/jquery.ui.widget.js”></script>

It groups the whitespace in front of the script element as well as the “../../”-part, and then just duplicates it, inserting the matched groups.