?
I'm not really a RegEx expert, but what you're describing should work. Without seeing the input, it's difficult to say.
I use http://regexstorm.net/tester to test it every now and then, since we use the .NET RegEx engine, so it might be helpful to make a test case in there first.
FYI: you can see exactly how the code uses regex, it's quite simple: https://github.com/Inedo/inedox-inedocore/blob/master/InedoCore/Common/Operations/Files/ReplaceFileTextOperation.cs
Can you share something that appears to work on RegExStorm , but not in the OtterScript plan? And then share the OtterScript plan?