Fancy String Replace
Perl 6, 76 bytes



{$^b;$^a;&amp;{S:g/$a&lt;?{$!=$/;all m:ex/$b/&gt;&gt;.&amp;{$!.to&gt;.to||.from&gt;$!.from}}&gt;/$b/}}


Try it online!

Anonymous code block that takes input curried, like f(a,b)(s). 

I'm pretty sure this matches up with the intent of the question. Basically, it only makes the substitution if the position of a is not within any of the overlapping matches of b.