Board Thread:Code Review/@comment-3279487-20170731202121

On my code MediaWiki:PreloadTemplates.js, I'm using this code to basically mimic the use of noinclude/includeonly tags. However, if you use the regex I'm using with this string, for example

... TEXT TO EXCLUDE TEXT TO INCLUDE TEXT TO EXCLUDE ... will match everything between the two most far tags, and therefore results in. What should be the correct regex instead? 