May the first be with you Write a program to replace all occurrences of "force" with "first" and all occurrences of "first" with "force", keeping the original case for all character positions:

"ForcefoRcefOrcE" -&gt; "FirstfiRstfIrsT"
"FirstfiRstfIrsT" -&gt; "ForcefoRcefOrcE"


The rest of the string must stay unchanged, and so running your program twice shall return the original string:

"thirst of forces" -&gt; "thirst of firsts" -&gt; "thirst of forces"


Your program should work on any initial string. So as a hint, you better avoid using magic characters as intermediate representation, because if you try a three pass replacement ("force" -&gt; "zzzzz", "first" -&gt; "force", "zzzzz" -&gt; "first"), it will fail on strings containing "zzzzz".

You should support the full range of characters allowed in a definition of a String by your programming language (in most cases, it's Unicode). Example, using JSON-style representation for non-printable characters (\u + 4 digits):

"\u0000\u0001\u0002\u0003the Force of the firsT"
                     |
                     V
"\u0000\u0001\u0002\u0003the First of the forcE"
JavaScript (ES6), 93 88 bytes



f=
s=&gt;s.replace(/force|first/gi,s=&gt;s.replace(/./g,c=&gt;s[s.search(c)^1]||c,s="oicsetOICSET"))
&lt;textarea oninput=o.textContent=f(this.value)&gt;&lt;/textarea&gt;&lt;pre id=o&gt;




Edit: Saved 5 bytes by optimising the unchanged letter case.