(.+?)
in regex means that there will be additional text after BEGIN
word, but looks like your test file just ends with this BEGINS
- so it cannot match it.
Try using *
instead of +
, or add some garbage to the end of file - depends on your real needs.
To solve your initial task - use for example Singleline mode, which greedy match the rest of file:
<FileUpdate
Files="@(FileToUpdate)"
Regex="(IF @@TRANCOUNT>0 BEGIN)(.*)"
ReplacementText="...I have replaced the first match only...$2"
Singleline="true"
Condition=""/>