I want to replace a string by another - the catch is that I need the original case to stay the way it was. If the string started with an uppercase, I want the replacement to start with an uppercase too. So I tried this:
$text =~s/\b(Abc|abc)\b/(Xyz|xyz)/g;
But it replaces every match of "Abc" or "abc" with "(Xyz|xyz)". So I'm guessing it's not possible to use a pipe within a replacement?
I also tried the following, which works perfectly fine:
$text =~s/\bAbc\b/Xyz/g;
$text =~s/\babc\b/abc/g;
...but I really wish I could do that with only one line of code. If it's not possible to have two replacements in one regular expression, is there any other way to retain the original case of the string?