I want to preserve all the cases!
I already long ago made an npm package that can do these kinds of replacements on text, because nothing else I found was as comprehensive:
https://github.com/jedwards1211/preserve-case
Trust me, it is way more comprehensive than anything else:
import replace from 'preserve-case'
console.log(replace.all('foo bar FOO_BAR foo-bar fooBar foo-Bar Foo_bar', 'foo bar', 'baz qux'))
// baz qux BAZ_QUX baz-qux bazQux baz-Qux Baz_qux
You might want to use it in this package.