@gfoidl, at least on my machine, comparing string.Replace in .NET 6 vs .NET 7, multiple examples I've tried have shown .NET 7 to have regressed, e.g.
string-replace-enhanced allow you to go futher with the command replace for string in javascript. You have two options, use the object and implement his settings or use the functions in a standalone ...