[Question]
  [
## *Back*ground
A **[backronym](https://en.wikipedia.org/wiki/Backronym)** is an acronym that was formed from an existing word. For example, *spam* is actually named after the canned meat product as used in the [Monty Python sketch](https://en.wikipedia.org/wiki/Spam_(Monty_Python)), but can be interpreted as "stupid pointless annoying mail".
## Challenge
Given a string `a`, and a word `t`, capitalise the correct letters of the words in `a` such that they spell out `t`. You should always move left-to-right through `a`, and capitalise the first occurrence of each letter.
For example, if `a` is `all the worlds a stage`, and `t` is `LAG`, then we walk along the letters of `all the worlds a stage`:
* we look for the first `l` and capitalise it: `aLl the worlds a stage`
* now we look for the next `a`, but it must be after the previously found `l`: `aLl the worlds A stage`
* now we look for a `g`: `aLl the worlds A staGe`.
You may assume `a` will only contain lowercase ASCII letters and spaces.
You may assume `t` will only contain ASCII letters. You should choose whether `t` will be input in uppercase or lowercase.
You do not need to handle empty inputs or inputs that have no possible backronymisation.
## Test cases
```
a                            t        output
================================================================
never gonna give you up      VIP      neVer gonna gIve you uP
all the worlds a stage       LAG      aLl the worlds A staGe
why                          WHY      WHY
baacbbccba                   ABC      bAacBbCcba
x                            X        X
xxxx                         X        Xxxx
yellow submarine time        YEET     YEllow submarinE Time
```
## Rules
* You may use [any standard I/O method](https://codegolf.meta.stackexchange.com/q/2447); also, you can use lists of characters or lists of codepoints instead of strings.
* [Standard loopholes](https://codegolf.meta.stackexchange.com/q/1061) are forbidden
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins
  
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 49 bytes
```
f(char*a,char*t){for(;*a;)*a++^=*a-*t?0:32+!++t;}
```
[Try it online!](https://tio.run/##RU/LboMwEDyHr9giRbIxqJSkl9KoH4KotLg8LFFA2JBQxLfTNSSKLzuznlnNyKCUcl0LJivsPfS3YfhctD2LPYy5h0J8XzwMPPMVfpwi8SKEiZf1F1XD@OxYA3hGJmkSpXCB2ZndJh/zHsq2aRBKNeYwtQMMneuDO6rOXXzSYF2DqXK4tn39owFBGyxzK6mx3CXXarLcjo1niDLLpES7xUzu25tltzumd6fOEjsOtQCmGgOKkoUxjU/Q6i9vC2Ykh9cHofycfoXglP/Q9WQpmHsMoncNx@CsgY5SRZUmYfpAbymPncNWH5NTmBLRppfdxPAptpLiudg93WA0Q0IUcv0H "C (gcc) – Try It Online")
Modifies `a` in place. Input `t` lowercase.
[Answer]
# Python 3.10, ~~76~~ ~~73~~ ~~47~~ ~~57~~ ~~51~~ 49 bytes
```
def f(a,t,i=0):
 for c in t:a[i:=a.find(c,i)]-=32
```
[Attempt This Online](https://ato.pxeger.com/run?1=NZA9bsQgEIXr-BQjKojYVbJpIks-yWqLAQ82EgYLY1ucJc02yZ1ylVSBrNPMn94MfO_ja85pDP5-_1yTOb1_v_ZkwHCUSdruRbQNmBBBg_WQWrzatsOzsb7nWlpxO3Vvl2PxJ9GSumvzxBk6B2kk2EN0_QIIS8KBmGQOByZklXjaKMIQvEcY7EaQwwrrXDSbnQ_NPubS1_joMzkXdlhWNWG0niDZqV7NROmQKEStlNYKyxyVZqK5NRVAyfUPofyxIBW6bsKZq5wIY8QseREIeXnmrNCU3RqFaGAuD6XqRqnNkY_ZuScdeuJCPBz4t_AX)
Takes in `a` and `t` as byte arrays with UTF-8 encodings with `t` lowercase, modifies `a` in place.
---
-3 bytes from @pxeger for replacing the double spaces with single spaces (I blame my IDE for auto-converting my tabs)  
-26 bytes from @Cong Chen because the rules allow you to take in a list of characters and modify it in place (I should have read the rules more carefully)  
+10 bytes from @Cong Chen because all of the previous methods just didn't work properly (not sure how to notate this)  
-6 bytes by using code points instead of characters  
-2 bytes from @loopy walt by using byte arrays & walrus operator
[Answer]
# [J](http://jsoftware.com/), 49 bytes
```
toupper@[`(0{"1[:(|.~"#:0,2>:/\{."1)^:_[:I.=/)`]}
```
[Try it online!](https://tio.run/##nVJbb5swFH7PrzgKVWw3xEAenQa5rbqtUrVNU7W1cmhjmEOZyEVA0lYk/PXMJmUbbZ@GBIjzXfA55/u171IUw5gBAhtcYPoeUDj/dvVhXyzXq5XKuJhit@x6guEtrboWc@2hz5xJSbseuWP3gl3SsUOmwW5POp/PKHxIkxXILF7P1aLIaWc2phBXnY6KHpaAnkIZhVGIZkiGEWqK@kIwAxs9NaVrlRcQyVzllNKmGJ7K6Cw8jySCgT5yKLVXGJnPGfzrt1DfVQbxcrGQEF9uFDwv17D@elAt1OYvmDTgqvbYJKvGQ16lUDwoeFxm6c8cTiEv5Ed1sJBpC5MGi1XtkMq4cfjx6fZAf3x4rjHzftVJ@KqV8HUv2EY3iBgONtMh7Snd1IMzBu@M8PYiTZePkK/DucySxQVcJ/OXBp5VC1JQ1NDMIKpAnXqRX3SLGciiUPNVYdZQV3UOsHfCLXpEXPB6ONCpGG5xv6S8pIQEZOzUPE2ZcIExJgmtSI/6Dt9SPqqIYH3HQMcvxCHeUbtyrUq8A7lsihPKhcnXGzhT0TrL9QoZ6JDiTUkFsZvY6vME9k4/jlgldrTy@psxTag@I6f4mAfWIa2tlLtb9ifmQ9@ZuPbblLdUuqNgigUbaVlgV/jS@JeibrdHt1SwE26EFZmKtlLLBtzigT5zLXVL7GutJciLsC377/6GA2cimNXzux427FHlM45r3k7b9XznjklWU3GA7lH3vh54YP7s9VurGzn73w "J – Try It Online")
This challenge resisted all my attempts to find a short array paradigm solution.
I tried more than 5 approaches, and my best result is still rather long.
It's interesting to contrast how simple it is to solve procedurally -- you need only a single loop and a single register.
## my best idea
The interesting part of the solution is calculating the indices of the uppercase letters.
Consider `'abc' f 'xbacbcb'`.
* First we construct an equality table:
```
0 0 1 0 0 0 0
0 1 0 0 1 0 1
0 0 0 1 0 1 0
```
* And then convert each row to the indices of its ones, with zero fill:
```
2 0 0
1 4 6
3 5 0
```
* Finally, we start rotating any "out of order" rows to the left. A row is
out of order if first element is not greater than the first element of the
row above. We continue rotating until a fixed point is reached: the entire
first column is increasing.
```
Focus on first column
|
v
2 0 0
1 4 6  <-- 1 less than 2, so rotate
3 5 0
2 0 0
4 6 1
3 5 0  <-- 3 less than 4, so rotate
2 0 0
4 6 1
5 0 3  <-- now 2, 4, 5 increasing, so done
```
* We now have our answer: `2 4 5` are the indices we need to capitalize.
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 55 bytes
```
[H|T]+Z+[X|P]:-[H|B]=Z,X is H-32,T+B+P;X=H,(T+Z+P;P=T).
```
[Try it online!](https://tio.run/##VYyxCsMgFAB/RZwUnx3arUFKzJItDg4hIZS0lSJoLGoJhfx76tiOxx33isGFJ0@r3fex3fTEBjb2m5rOvKCcxAA9sgm1/HQEzSRTVS9aILp0qlJC08N@4WjOwV/v4WESwR/jXFhRet/8HO1iULbeYKgp/FcmY5AU6jJtflUHDYU12mzcQrry/wI "Prolog (SWI) – Try It Online")
-33 bytes thanks to Jo King
Recursive.
# [Haskell](https://www.haskell.org/), 44 bytes
```
x#[]=x
(h:t)#a@(x:b)|h==x=h-32:t#b|1>0=h:t#a
```
[Try it online!](https://tio.run/##bZDNasMwEITveYpBLkUiCfTnZnAolN7aU49pKCtHtkxsyVhyIkPe3ZUd6MHtgtDufDMgrSZ3UnU9jiHZH7Kw4jr1IqEXHlIprjrLQqa3z0@pT@T1cfeQRZzQWJm29w4Z9pwZdVYdSmsMoazOCoPt0bdsA3auWiY2K/wWZ1TX8FrhYrv66EBwnko1mWsql@aLHiYyXQsiiXIp81zSZCCZLw1h0sMfNda/YIg7sBe4XjbUVUbBV838qkEpz8Rh1VBl4n@PNsYaaj@@wb94sXEC2x3iMj59925whwLrNRju44mNu03RMo88JmMuTIK3b6ZvEJCmeNXUiRieedHZZkaFQLKQnBACt@WPPw "Haskell – Try It Online")
I/O as codepoints. -2 bytes thanks to alephalpha
[Answer]
# [Curry (KiCS2)](https://www-ps.informatik.uni-kiel.de/kics2/index.html) + `:set +first`, 61 bytes
```
import Data.Char
(f s)#(g s)=s
f=map toLower
g=filter isUpper
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m706ubSoqDI-OzO52GjBgqWlJWm6FjdtM3ML8otKFFwSSxL1nDMSi7g00hSKNZU10oGkbTFXmm1uYoFCSb5PfnlqEVe6bVpmTklqkUJmcWhBQWoRxJDduYmZeQq2CkpJiYnJSUnJyUmJSgrKCkqOTs5KEBWbopWsilNLlHQUlLTTMouKS5RioQ4AAA)
`a # t` finds a string `s` such that converting `s` to lowercase gives `a`, and picking out the uppercase characters in `s` gives `t`.
Curry is a functional logic programming language. It searches for solutions using backtracking. Without `:set +first` it would return all possible solutions. With `:set +first` it only gives the first one.
This works on KICS2 3.0.0. It seems that it does not work on PAKCS or older versions of KICS2.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 12 bytes
```
v=vTΠ~Þ⇧h⁽⇧V
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJ2PXZUzqB+w57ih6do4oG94oenViIsIuKIkSIsIltcIm5cIiwgXCJlXCIsIFwidlwiLCBcImVcIiwgXCJyXCIsIFwiIFwiLCBcImdcIiwgXCJvXCIsIFwiblwiLCBcIm5cIiwgXCJhXCIsIFwiIFwiLCBcImdcIiwgXCJpXCIsIFwidlwiLCBcImVcIiwgXCIgXCIsIFwieVwiLCBcIm9cIiwgXCJ1XCIsIFwiIFwiLCBcInVcIiwgXCJwXCJdXG5bXCJ2XCIsXCJpXCIsXCJwXCJdIl0=) I/O as char lists.
I feel like there's gotta be a smarter/faster way to do `Π~Þ⇧h`.
```
v=           # Create an equality table
  vT         # Get all indices of each letter in the string
    Π        # Take the cartesian product, getting all combinations
     ~Þ⇧     # Filter by those which are strictly ascending
        h    # Get the first, which will be the first occurences
           V # To those indices in the original string...
         ⁽⇧  # Uppercase them
```
[Answer]
# x86-64 machine code, 11 bytes
```
AC AE 75 FD 80 67 FF DF 75 F6 C3
```
[Try it online!](https://tio.run/##dVLfa9swEH6W/oqrR0Buk9JmZYxk3sN@vQ1G6UNL0sH5LNsasmQsOYk3@q/PO2fdoGUTSHfc3Xffd4doURGNI4YGFFwnSp5X1udooZTlSlhfhFx2tBKBkD3xzWnoSAp0Bby7u/kIX26uYdMVZnF5P4eLw4dPU813RotOR5kmkK4l1dhBqY7mFOfw24mckS@MI9sXGt6EWBh/Xr99EuqMq6aYcREaNE6l8ocUR3zcXC5fMyce7VqKfW2sBsVCXamSWYDZ5uvW3UMyh8hlKWQZLFMpuIEoFcuYBAjR9jEonNwHKVomjIzeus9IteFhyRd6lUxp8i5E6F0wldPF4xAtZKD@mUnL9bMQcZPCwx8OmF0sb1kcZaft2Vm6hscBCE4y3uT7lxPp32I1M5APUYd06xjULv7HyqiHcdyZVji90x1U3jmEyuw0DL6HvpUWK4HWQqw17H1niwAIIWKl5b4eeI@DxJxEjkh5TpSjPIjDdPnIQesoBm2t30Po8wa7aUvRNPonldw5jIvm1RU//KMy1q7tLw "C (gcc) – Try It Online")
Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes the addresses of `a` and `t`, as null-terminated byte strings, in RDI and RSI, respectively, with `t` lowercase, and modifies `a` in place.
In assembly:
```
f:  lodsb       # Load a character from t into AL, advancing the pointer.
rc: scasb       # Compare AL with a character from a, advancing the pointer.
    jne rc      # Jump back to repeat if they are not equal.
    and BYTE PTR [rdi-1], 0xDF  # Set bit 5 of the matching character to 0, capitalizing it.
    jnz f       # Jump to the start if the result is not 0.
    ret         # Return (once the null terminator is reached).
```
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 27 bytes
```
i+`(.)(.+)/(\1)
$3¶$2/
¶|/
```
Takes input separated by `/`.
[Try it online!](https://tio.run/##K0otycxLNPz/P1M7QUNPU0NPW1NfI8ZQk0vF@NA2FSN9rkPbavS5/v@vTM3JyS9XKC5Nyk0sysxLVSjJzE3Vj3R1DQEA "Retina – Try It Online")
[Answer]
# [R](https://www.r-project.org), ~~55~~ 54 bytes
```
\(s,t)sapply(s,\(c){if(F<-t[1]%in%c)t<<-t[-1];c-32*F})
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhY3zWI0inVKNIsTCwpyKoHMGI1kzerMNA03G92SaMNY1cw81WTNEhsQT9cw1jpZ19hIy61WE6rbq9gWyLAIyffMK9FQSszJUSjJSFUozy_KSSlWSFQoLklMT1XS5CpBVpWTmA4UyswrCckPBYpqpIEdADVxwQIIDQA)
Input is vector of codepoints.
---
# [R](https://www.r-project.org), 61 bytes
```
\(s,t)for(c in s){if(t[1]%in%c){c=toupper(c);t=t[-1]};cat(c)}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VY5BCoMwFET3PUUICPlQF-4EyS3alXUR0sQGPonkf-lCPEk3ttBD9TaV6qarYXjDzDyeeXl5_R7Zl_VHXxQdGXzKyooQBcEUvOK26ooQCwuT1ZzGYXArh4Y1t2XVzY01vPp5L2lJO1TEmQYMrKRBFHxz4p4yXkkYQWx6J49SAhz4P4um30EcEXWIfEpn9rXyv2OwTSzLpl8)
Function with null return value that prints output to console.
Input is vector of characters.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 9 bytes
```
£ƛ¥h=[&Ḣ⇧
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJzIiwiIiwiwqPGm8KlaD1bJuG4ouKHpyIsIiIsInllZXRcbnllbGxvdyBzdWJtYXJpbmUgdGltZSJd)
Literally is different by one character from [this](https://codegolf.stackexchange.com/a/249833/92689), and also very similar to [this](https://codegolf.stackexchange.com/a/249605/92689).
Input as strings, output as char list. (`s` flag in link smashes)
```
£ƛ¥h=[&Ḣ⇧
£         # Put the first input in the register
 ƛ        # Map over the second input:
  ¥h=[    #  Is the current character equal to the first character of the register?
      &Ḣ⇧ #  If so, remove the first character of the register and uppercase the current character
          #  (implicit) else, return the current character unchanged
```
[Answer]
# [Java (JDK)](http://jdk.java.net/), 40 bytes
```
a->t->a.map(c->t.peek()!=c?c:t.pop()^32)
```
[Try it online!](https://tio.run/##bVJRi9swDH7vr9AKBWck5ra9NdeMMRgMbk/d23EDxVVSt44dbCVtGPfbMyfXretuBluWvg/pk@wD9pgddsdRN63zDIfoy461kW/zxatY1VnF2tn/goE9YTNBymAI8A21hZ8LgLYrjVYQGDma3ukdNBETW/ba1o9PgL4OyUwF@HIpcb@d091/tUw1@SL9Azxoe6Tdgw58Bf8hFwVUsBkxKzgrUDbYChXvsiU6iuTNRn1U6@i5ViQ/PrxPxnwuXTkPokc/6YH1jSqAKR5gM0VlaI1mscyXSf4XihENj3dPUu3RB5HI0p1pJ244PHPeveJI5YwhxeLzi3U@SHYXJzYtrk2v15ZOyU1Wv6kktq0ZBCaXCydT199dnIjQWaGTmO6T9zhc9VzMdghMjXRdHEh8D67EchVSWAXIiniu7DKd20pn4SnE6vDycsKnd6mXhmzN@9@KnhfTfh5HSz15qJ21CLXuCQbXQdfmvW5HNAZ4T3By3uxCnFz8GzXlBuvxtB/yuMcSUZWlUiXmWKrxnJ/Hc1zRDGSMO0HoygajDALWDeUDEf8C "Java (JDK) – Try It Online")
With `a` is an `Stream<Integer>` (stream of codepoints) and `t` is a `Deque<Integer>`. Both inputs are lowercase.
There's a lot going on with automatic null tests, autoboxing and friends, so this answer might seem trivial, but it's actually not at all.
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 24 bytes
-1 byte from @ngn's improvement
```
{`c$x-32*y{y_x,y~:*x}/x}
```
[Try it online!](https://ngn.codeberg.page/k/#eJxVjs9rwjAYhu/9Kz6CByu6wXZrTk5kG+ywQ9kUKeuXLK1hsZH0V0LRv32JqwxzeCHv87zwFcmQ84ldPD7M3OC+7Nydk5k93dtTFEVpMkx27mySAu7A0lz/0GleoFTUUkdNnHkp3U1JJTphoNRVhVDKToDTLbRHQkknjySmXvj4F16vwjvJLnNUCpq9gF4b9V0DQt1gKfxaYRnW+HbDl4E/i3Hc7503Q3rz82U71gyRM8Y5Q0+R8UDZEvkTW4XuIs2JJTRE7HMzDq1/15Zswuevd0Ip3UPdsgMaWQlo5CHc6IRogrpd3/A1pIFnv8PQblo=)
Adapted from my answer on the [Speed of Lobsters](https://codegolf.stackexchange.com/questions/217690/speed-of-lobsters/218688#218688) code golf.
* `y{...}/x` set up a reduction seeded with y (the characters to search for), run over the characters in x (the full string). confusingly, within the function itself, x and y are flipped. this ends up returning a boolean array with 1s in the positions containing the desired matches and 0s everywhere else
	+ `y~:*x` compare the first character to search for (`*x`) to the current character being iterated over (`y`), updating y with the result of 0 or 1. note that as soon as we have matched all the search characters, no more matches will be identified (since a character will never ~ (match) a 0 or 1)
	+ `x,` append this result to the list of characters to search for (essentially overloading the reduction to end up returning the desired output)
	+ `y_` if there was a match, drop the first character (if there wasn't a match, this is a no-op). this allows us to search for the next search character in the next iteration of the reduction
* ``c$x-32*` multiply this bitmask by 32, representing the offset necessary to capitalize characters at truthy indices, subtract it from the original text, and convert that result "back" to a string/text
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 62 bytes
```
f=(a,[h,...l])=>a.replace(eval(`/${h}(.*)/i`),(s,t)=>h+f(t,l))
```
[Try it online!](https://tio.run/##jZJfS8MwFMXf8ynug7BEYwa@SoUpRQUfBMU/TGG32e1aSZPSZl3H2Gefqd0miorn6XDP7xAuuW/YYK2rvPTH1k1ps0kjjnKcSaWUeRXRGaqKSoOaODVo@GR4sMrWXB2KYT4RktfSByg7SrmXRoiNp9pDBBNmqaEKZs5ahFneECzdHOYlfOjh@rY3lh4@qesddcvQGPAZwcJVZloDQu1xRn0HbkaXvcGbL9Sooy6JLbIl/KrHq@e9YQmiThKt8SdydH7Rm2SE@jy50Mha@ENPe8PaoH9wgWJLMsYtoJ4nBVa5JfB5sVsUnuP4fmu@UDHcB4rVLqBzO6U0FKeQUUWfz9zFO@OK@BvFJspXecGFqkuTez54sQOhCix5C9EZtNvxEFYncj3sk6ZLmm1PiFPWfbVKXRWjzjgftxKWEuhVdNyKAWhnwy24cA0p78JQ6YfOkDJuxkMURUASXIjW4nTzDg "JavaScript (Node.js) – Try It Online")
Input uppercase `t`.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 11 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
v¬yQićuëy}?
```
Based on [my 05AB1E answer of the related challenge](https://codegolf.stackexchange.com/a/217695/52210).
Inputs as lowercase strings in the order \$a,t\$.
[Try it online](https://tio.run/##yy9OTMpM/f@/7NCaysDMI@2lh1dX1tr//1@ZmpOTX65QXJqUm1iUmZeqUJKZm8pVmZpaAgA) or [verify all test cases](https://tio.run/##PYy9DcIwFIRXeXLNDp6BOorEs3lyLDl2FP8kLtJCzxpQM0BgEhYxTpC44nTf6XTOo9BUUuYMPpcbMJ5PvqT1kY/6fY2ve154WdYnL03DLCUaQTlrEZROBNlFiAM7sKQH1h4ahsZA6AgmN5qzBwQfUFEdGFT7YOpypc03EohSCCkF1hKF3Mu55vmXqv6QyRg3gY@ix1FbgqD77TkTBda2Xw).
**Explanation:**
```
v        # Loop over the characters `y` of the first (implicit) input-string `a`
 ¬       #  Push the first character of string `t`
         #  (which will be the implicit second input-string `t` in the first iteration)
  yQi    #  If it's equal to character `y`:
     ć   #   Extract the first character from string `t`
      u  #   And uppercase it
    ë    #  Else:
     y   #   Push character `y` as is
    }    #  After the if-else statement:
     ?   #  Pop this character, and print it
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog) (v2), 10 bytes
```
↔{|ụ}ᵐ↔w₆⊇
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1HblOqah7uX1j7cOgHILn/U1Paoq/3/f6WkxMTkpKTk5KREpf9Kjk7OSgA "Brachylog – Try It Online")
Function submission, using both its arguments (input string on the left, uppercase acronym on the right) and outputting to standard output. Very inefficient (O(2*n*) performance).
## Explanation
```
↔{|ụ}ᵐ↔w₆⊇
     ᵐ      Iterate over {the left argument}
↔     ↔       in reverse order
 {|           either doing nothing (try this option first)
  |ụ}         or uppercasing {the character being iterated over}
         ⊇  such that {the right argument} is a subsequence of {the result}
       w₆   and when we find it, output {the result of the iteration}
```
Uppercase some of the characters so that we can find the acronym in the uppercased string. The inefficiency comes from the fact that the iteration order will try uppercasing the first character, then the second, then the first two, then the third, then the first and third, then the second and third, then the first three, then the fourth, etc. – the interpreter doesn't realise that the first solution it finds will uppercase a number of characters exactly equal to the length of the right-hand argument (because any solution which uppercases too many characters will be found later, and any solution that doesn't uppercase enough won't match), so it just tries all possibilities within a given prefix before going onto the next character.
Iterating in reverse is required for the uppercasing of prefixes to be the first thing the interpreter requires (with the normal iteration method, it would try uppercasing the last character first, etc.).
`w₆` (which outputs the current value, without discarding it, and where the output is used only if all the constraints in the rest of the program end up matching) is by far the most useful of Brachylog's nine write instructions, so could probably do with a 1-byte representation (I would likely make this the default behaviour for a write if I were designing a Brachylog-alike from scratch).
[Answer]
# [Perl 5](https://www.perl.org/) `-plF` , ~~36~~ 35 bytes
*saved a byte by taking the first input in upper case*
```
$_=<>;s/./uc$&eq$F[0]?shift@F:$&/ge
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3tbGzrpYX0@/NFlFLbVQxS3aINa@OCMzrcTBzUpFTT899f9/H0d3rsScHIWSjFSF8vyinJRihUSF4pLE9NR/@QUlmfl5xf91fU31DAwN/usW5LgBAA "Perl 5 – Try It Online")
Takes `t` on the first input line in upper case, then `a` on the second line.
[Answer]
# [Rust](https://www.rust-lang.org), ~~149~~ 148 bytes
```
|m:&str,v:&str|{m.chars().fold(v.chars().peekable(),|mut a,c|{print!("{}",if a.peek()==Some(&((c as u8+32)as char)){a.next().unwrap()}else{c});a});}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VZFNTsMwEIXFtqeYZlHZInQBm6pVF2mFSqUuKiEVELAYu5M2InGixElbJbkFOzZdwAE4DpyGOOmPGMl-nqdvLOv54zNOE73_dhUE6CnGc580uDD8SrV71ft5L4J-J9GxndVS5EFXrjFOGO-6ob9k2amNiN5Q-MS4XQSpBrRlkUexp3SbWXlp2Z4LWFOMD4f3YUCsw5gETCDtXd5c8-pg7uI8x66ira7uTNUmxojxkvyEclnyAVarbN72ezGFqgZuGANDG4QNtI1Ialpy8BRkJNvPzFKUUQyrUCmElZcR7MIU0siywVpM50YULc7E9EjMLW4Ds9D3Qa8JNmHsLxNASDSuyIzNnIkRnP0DHANMqBnerHcGebh7OkptC0QphJRoXGc0NiIclCMxlgIbZmvMx2ZrjKrOnmn4K-QtOJRbRSD44NTXyfuqyv5Fw-0hlz6YjzjH1OBl65Doft_oHw)
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 15 bytes
```
?Lqrd4h+Q0.(Q0E
```
[Try it online!](https://tio.run/##K6gsyfj/396nsCjFJEM70EBPI9DA9f//aKUwJR0lTyAOUIrlilbPU9dRUE8FEWVwVhGIUAAR6SAiH0TkwYlEVNlMVL1giUq4tlK4GJhVoB4LAA "Pyth – Try It Online") -- [Try with formatted I/O](https://tio.run/##K6gsyfj/3zYwNyXQ1j03xbXY3qewKMUkQzvQQE8j0MD9/3@lMM8AJS6lvNSy1CKF9Py8vESF9MyyVIXK/FKF0gIlAA "Pyth – Try It Online") -- [Try all test cases](https://tio.run/##NYnNCsIwEAbvPsUSL4IgPXgtUiVUoQcD4s8xaUJTSNKapK15@rgeXNgZPmZMUedcMivZuqytpOHQvL3c6y0rdhtW1PBrNGdyv1zJijg1Kw/d4ByHrp8VpGGCacTSVDWSGwNRK1gGb2QADiHyTmF4nF/IRSdkdTwhBeetEG0rOI4n/udvPNSL0hsqKWOGBcIkLPe9UxB7q8gX "Pyth – Try It Online")
Accepts `t` then `a` on separate lines as lists of characters and returns a list of characters.
[Answer]
# [Factor](https://factorcode.org/), 55 bytes
```
[ [ over index cut capitalize swap write ] each print ]
```
[Try it online!](https://tio.run/##jZFPSwMxEMXv@ymeufsF9FQ91IKIIP6j9DCZjttgSNYku9ta@tnX3bVxEYr4DsOQeb83kHkjTj50jw@Lu/kF3iU4sYjyUYtjiaDIxvQ1eo4wHpdFsS/Qaw/lpJGA0jtHKE0j2PkadaUwSjWmbw9jfwYnT5N3kb33OYqsRdoIWh/sut@KmKiUYxKUpXKKottf3tngnUtOaje7jJ3Q9zgnPd@8ZkwTsdbMdBJWpHnC9Iz4Sl@zpkxv/1iJ4zjTLz9QL/VfqPcWh6JbYgk//Lpxa9mC6wSmyiSy5lMQW6rQBpMEKwjxBlUwLmHVjQc8H566Lw "Factor – Try It Online")
Takes the string and the lowercase word in that order. Assuming the input is `"all the worlds a stage" "lag"`
* `[ ... ] each` For each letter in the word...
```
        <<iteration 1 of each>>
            ! "all the worlds a stage" 108
over        ! "all the worlds a stage" 108 "all the worlds a stage"
index       ! "all the worlds a stage" 1
cut         ! "a" "ll the worlds a stage"
capitalize  ! "a" "Ll the worlds a stage"
swap        ! "Ll the worlds a stage" "a"
write       ! "Ll the worlds a stage"    (write to stdout without newline)
       <<iteration 2 of each>>
            ! "Ll the worlds a stage" 97
over        ! "Ll the worlds a stage" 97 "Ll the worlds a stage"
index       ! "Ll the worlds a stage" 14
cut         ! "Ll the worlds " "a stage"
capitalize  ! "Ll the worlds " "A stage"
swap        ! "A stage" "Ll the worlds "
write       ! "A stage"    (write to stdout without a newline)
     <<and so forth..>>
            ! "Ge"
print       ! (write to stdout with a newline)
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 36 bytes
Takes the string as first argument, then the acronym in lowercase.
```
{@[x;(#x)-1+#'x{y/1_y\x}\y;`c$-;32]}
```
[Try it online!](https://ngn.codeberg.page/k#eJxNjcsKwjAURPf9iksqqGiR6s5s/I+26E28rYE0KX0mlP67ad04i4EzHJjyPj8yxw+xOybpKd672V/Sp8/dknv+kruE367FEkVlxgyN1EJljUGo1Ejg7QBDwzgbVcOKVUGtof8QTLbV7w4Quh4rCobG6mdMHx9w7Q0FohRCSoFhRSG39cwc42ttigv5Q09a2wm6QdTYKkPQq3p98EQ9K76bIEHe)
[Answer]
# [Go](https://golang.org/), 70 bytes
```
func s(a,b[]byte){i:=0;for _,c:=range b{for a[i]-32!=c{i++};a[i]-=32}}
```
[Try it online!](https://tio.run/##PY5BCoMwEEXXeoppVhFtKbpTcoDuXHUjUkaJIbQmEqMgIWe3sUJ38x8z74/Q@4T9GwWHEaWK5ThpY8kwWrIPi@phpph1TdttlidOluxeDdrAK@tLZlCFs84dABvZXov8wnon09RXv8yK3PtTc8hpAi6OEEoGp5ASxVduQGilEIRcOWx6gWUiSRwdxf@956MmSYDhr1ttpLIfRWcbBkExcL9/AQ "Go – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 16 bytes
```
ẹⱮŒpI>0PƊƇḢ
Œuç¦
```
[Try it online!](https://tio.run/##y0rNyan8///hrp2PNq47OqnA084g4FjXsfaHOxZxHZ1Uenj5oWX///@vBKrKL1coLk3KTSzKzEtVKMnMTQWKppYAAA "Jelly – Try It Online")
```
ẹⱮŒpI>0PƊƇḢ - Helper link g(s, w) - takes string on the left and word on the right.
ẹⱮ          -  For each character in w, get all indices of it in s.
  Œp        -  Take the cartesian product over this list.
         Ƈ  -  Filter keep for:
        Ɗ   -  Last three links as a monad:
    I       -   Increments (deltas / consecutive differences)
     >0     -   Are they greater than zero? (positive)
       P    -   Take the product of is to check that all are truthy
          Ḣ -  Get the first item (that satisfies that condition)
Œuç¦   - Main link f(s, w) - takes string on the left and word on the right.
  ç    - Run the helper link (as a dyad, given s and w)
   ¦   - At those indices in w...
Œu     - Uppercase them
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 22 bytes
```
Ｆη«≔⌕θ↧ιζ…θζι≔Φθ›λζθ»θ
```
[Try it online!](https://tio.run/##RcyxCsIwEMbxuXmKGxOIT@AkBUVw6OQe4pkEQq69tpFWfPbYKOj2h/t9Z71hSyaWcicG6RU8RXMYx@CSPIZ0k4OGCz2QrRlRBqU0rGovmo5DmmS72Iitp76yVf0PoebvTZyQqzgxmprxgzUMm3qJ72LrUhJmZHCUkgEXMsJCM8y9uJ67ssvxDQ "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｆη«
```
Loop over the uppercase letters.
```
≔⌕θ↧ιζ
```
Find the index of the next matching lowercase letter.
```
…θζ
```
Output its prefix.
```
ι
```
Output the uppercase letter.
```
≔Φθ›λζθ
```
Remove the prefix and the lowercase letter from the string.
```
»θ
```
Output any remaining lowercase letters.
[Answer]
# Regex (GNU ERE or better), 30 bytes
```
s/(.)(.*(
))(\1)|
/$4$3$3$2/ig
```
[Try it online!](https://tio.run/##bZLfbtMwFMbv8xRn0TTba@uu226gpKigaQzxTwwxprZoTuKmHo5jbKddt5VLHoBH5EXKSacOLoil6Pic4y8/fyfXYi585pQNHVPlcn2bHPRdch6cMgV3YnG19l3KGeX7NGKMjnvsPuruHu8e4TrsqmJ9xb1WmaS9dqfH@qCmQN3oYLKTEE8YhJmrFkDeKu9REGIfkyiHBNyoN3lozgfkB4H7e8h5KUI2o93RQefJsDOeiM5ql7L9Fn82eP510mWPamdmLrTKIZdalSpIRyLXaHJvtQo032JwLU0RZrCTwPHj4QtXIYipy1Q6qKZ/RTzpg9@gHSJaI/hRFic3ljasbUwfTVjk5PdaOUmJkyLXykjCeIZxkGcGNaYCnbhTxtbhqXVVJr3nPuTKrBivDCWbE22dDO5uYW8P/mmp6sAXDjkoGRuCN7hNehGARYzX5@/fcSucx9qItHSLTPCr15Uy295p5Wi/z@5K7LbcSasbDtcGv7GClkliWYqY3/pgk3K1sUfjlJKExDil/3JoaEEMv3/@wnfrAcJvfgs1XVLL2IqtYyPn6GJRGSOgUHMJy6qG2sZtiD@ffYijWGiNxktYVE7nHgT4IArZ1N8MT7G@mC2bzcWrS9ykQmRpmmWpaHLDFy8xd9OEX5oAn228lFrjLH2dlgKJJARVbkQvT04@xX8A "JavaScript (Node.js) – Try It Online") - ECMAScript  
[Try it online!](https://tio.run/##TU7LTsMwELznK1aWpcQopA2PS02BQhEPIUACAVUbRU7qpkFuUvJoqEqufACfyI@ENaUC78GzM7uzM5eZ2m/KXMLV/e0NB436ohCdTr@czWXGjUmaWTTutvnBIcffZSuIJ8iw1TyLkwLIKCG8BqqgC3kZ5AWO@/a2a7tMvmoRjv7xbVQYdID63AA0AmujKdT0iklMtqIC3cYyTMfSf8nTBMyh6VDlmJ7JYX0XF0z4@vgEZKiP48e4VQ/bnqOPOuvO9Ti4UE1jJZu8ZTnMcrYsgzFr5LJ3o0X36C7WTiuOmo3vbx6Z/B0fUt@zwbUBs/O6bkgiFzKDKE0SAVG8kLBMSyjnxAbyeHlHDCKUgmIqoUozNc5BQF6ISGr9uneOejVd6ubpYoBNIEQYBGEYCM31Tk6Re9PwWQN8G7yUSqWVTjgTmFVCEc9@TAdnZw/kGw "Perl 5 – Try It Online") - Perl  
This is a single regex substitution to be repeatedly applied until it has nothing to match (or until there is no change, in engines whose API doesn't supply the information as to whether anything was matched – i.e. ECMAScript, Boost, and Python).
Input is taken as string `a` and word `t` concatenated with a newline delimiter between them.
This is similar to [Leaky Nun's **27 byte** Retina solution](https://codegolf.stackexchange.com/a/249808/17216), but that one does two regex substitutions (looping the first until there is no change, then applying the second one once, then done) and uses two different types of delimiters at once (newline and slash), while this solution does just one looping regex substitution, and only uses newlines as a delimiter.
The intermediate states as this one progresses are different than those in the 27 byte Retina solution. In it, as the first stage progresses, it inserts a newline after each capitalized letter in string `a` and deletes the corresponding letter from the beginning of word `t`. It's only in its second stage that the newlines in string `a` are deleted.
As this 30 byte regex substitution progresses, it inserts two newlines after each capitalized letter in string `a` and deletes the corresponding letter from the beginning of word `t` – but as it progresses, the previous double newline gets deleted; at any given step (other than before it starts), only the letter last changed to uppercase has two newlines after it. Then when no letters are left to capitalize, it deletes all the newlines.
```
s/            # Match the following:
    (.)       # \1 = $1 = one character from string A (which is in lowercase)
    (         # $2 = concatenation of the following:
        .*    # Match as many non-newline characters as possible, minimum zero
        (¶)   # $3 = one newline
    )
    (\1)      # $4 = the first character in word T (which is in uppercase)
|         # or
    ¶         # One newline
/             # Replace with the following:
$4            # The uppercase letter from word T, replacing $1
$3$3          # Two newlines inserted
$2            # $2, preserved unchanged from string A
              # No $4 – it is deleted from the beginning of word T
              # Note that all of the above will be empty if the second
              # alternative, one newline, was what matched, thus deleting
              # the newline.
/             # Flags:
i             # Case Insensitive
g             # Global - replace all matches instead of only the first. After
              # the first match is made, each additional match attempt begins
              # after the end of the last full match (i.e. they don't overlap).
              # The replacement pass is only done after all matches are found.
```
## \$\large\textit{Anonymous functions}\$
# [Ruby](https://www.ruby-lang.org/), 52 bytes
```
->s{0while s.gsub! /(.)(.*(
))(\1)|
/i,'\4\3\3\2';s}
```
[Try it online!](https://tio.run/##NVDLTsMwELznK7a@OKFp@oCbFaSCKh5CgAQCqiQHp92mrlwn2ElDC1z5AD6RHwlOELZkzczOrFerq3TfaHythEagG5MrymAVNoNT8z6q10IimCAzVdqDoRt4bnDkOp7nxmPvwxkKn8Yn8bG9E8rMZ3MIRwz@QjLMsDQOgFjBoWf1oioNQ7Vkh3DMWlVGg3EShiRWhFm7jEZBMJgkDKzpL2cla6CEWgpgIITrh7vboODaoEsj2pd9mlAv2ORCuW0frzMWWqgSpE/g5@sbiN@FMlSoeYnuKjKJ133SPQ1RuEMNWa4Uh0zsEPZ5BVVBfCBPV/fEIVxKKNcIda7l0gAHU/IM2/rN9MLW6/W@Jc@Xc0tSzhdpulikvNWmZ@dWe2vhSwvs@cd7lDKvwW52y@3ACKXYdk3ns9kj@QU "Ruby – Try It Online")
## \$\large\textit{Full programs}\$
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 28 bytes
```
i+`(.)(.*(¶))(\1)|¶
$4$3$3$2
```
[Try it online!](https://tio.run/##K0otycxLNPz/P1M7QUNPU0NPS@PQNk1NjRhDzZpD27hUTFSMgdDo///K1Jyc/HKF4tKk3MSizLxUhZLM3FSuSFfXEAA "Retina – Try It Online")
# Perl `-p0`, 37 bytes
```
1while s/(.)(.*(
))(\1)|
/$4$3$3$2/ig
```
[Try it online!](https://tio.run/##K0gtyjH9/9@wPCMzJ1WhWF9DT1NDT0uDS1NTI8ZQs4ZLX8VExRgIjfQz0///r0zNyckvVyguTcpNLMrMS1UoycxN5Yp0dQ35l19QkpmfV/xf19dUz8DQ4L9ugQEA "Perl 5 – Try It Online")
# [GNU sed](https://www.gnu.org/software/sed/) `-z`, 39 bytes
```
:a
s/(.)(.*(\n))(\1)|\n/\4\3\3\2/Mig
ta
```
[Try it online!](https://tio.run/##bU7NTsJAED7bp5isJNttoA3qiUIIGlQSTUw0KmHBbNtN22TZkt1CLdmzD@Aj@iJ1i3Bz5vL9zHwzEdNZozhLoKcSwBjUcIg/joWbAXN04PrE9T2XSkJc2ieGyoBe0UvbF8Fjnjola04bTpXlgsPs9nkEx1QQxiygJwF1BIJlmBTOmeV76GhYGsPjrAj1qB@24DBjNlwJ6G04YB2skOuOB5T6ZrFCS@IRBF4XvH9UK5z7HhkHtE@l/Qwb9xD5dxl@vr4BYYRD0Ny@Nd1zKysUwmnIesRJCskbJPmOK0gLKRmk@Y5DXWxhu0FdQK@zJ@QgJgSUGYeqUCLRwECXLOWt/zC5s36V1S15u59bEjEWR1EcR6zVJtc3Vvts4XsLbJ1wzYUoKtDbaM1ULjmU@foQOp9OX9Av "Bash – Try It Online")
The `M` flag tells `.` to match everything except newline, whereas normally in sed, `.` matches any character including newline.
[Answer]
# Regex (.NET), 69 bytes
```
s/.(?=(.*$)(?<=(?=(?>.*?(.)(?=.*
((?>\3?)(\2))))+\1$)^.*))|
.*/$4/img
```
[Try it online!](https://tio.run/##lVTdbtMwFL7vUxwZS4lLk63ADSuhjGqDISZNMDFQF8BNncTIsYPtrC1duOQBeEReZJysUKjEDeciOj@fP33n@MS1WQjrSqHUDbXJk@DG7cXhOAnjPmXh@FHS@ePHcX8cxhgncb8XYnx5f8zCy3sM7e7lkLL3cZ@x617c36MP9mRV3ARPRjIPqZ3up5EWxBG29qU1CwhOpXNSF4C5oKXzBDHD9BY8jwpPvpLI2HBqRSGWaTDdjx4eRpcpj1oasv7d@NHj8fs0YPEp91kpHB5iW@YTfcWVnMNcKFlJLyzyW@SPX9dK@g660RQroQtfoi54sD18YQ2K0k01ExZM/ofEBW2Puk7mvXQEtEiG@M0TMjFVLZWYkxFMs5LbaZoi5n56fWzsEc/KtVtI1BjSD2zdA7SgCGBNC0ggGrabjOwyOWYIXeft4KTQxooJd4L8AlS7gNNGeamk3tbdbv01DlaJvwF6F3C0xFFk0k947Ru7RS3/peOMe2xfX5Q4BVfzbIu2u@hXsij9uXkpck9auLU7kDXOmwoi0MaDa@raWC/mMFtBOM4VLxi4lfZ8uWHMdhkn2Caq6@7TSq472v9gbPG@bPJrgw4OtFiEtzs2oDnr0S/J/ijH7nh3NQqkBip13Xi27nZDdfsqPgck2MRf2Hphsf@oNM63eHg4@hNDpA2yd@NG4Qp@fPsONJwYfSUsDiR64Qyy29iKWuH4wt@lY2uqTZFMqUoJiz4Z1EE@6o9kQN2AFoyRtr0hWiAcCqM1h0JeCViZBpqaDIC8OTkjPcKVAl8KWBir5g44OM8L0dVfHj7D@qJcdcHF83cYzDjPZrMsm/Eud/h0grll577tHLTf/gofA/wlXDOrcP7YnJfVLem7o6Nz8hM "PowerShell – Try It Online") - all test cases  
[Try it on regex101!](https://regex101.com/r/H2drs5/10) - try it on your own
This is a single regex substitution, to be applied once. This is the only kind of substitution that can be efficiently used on regex101.
Input is taken in the form of the two strings delimited by a newline.
The primary challenge here is that each match+substitution must be done as a separate event, with no communication between them (other than that each subsequent match is done following the end of the previous one). No captures can survive from one match to the next, so each one must reconstruct its state from scratch, relying only on the position of the match to let it do that.
Also note that the actual replacement is only done after all matches are found, so that can't be used to communicate state.
In this explanation, a raw newline is shown as `¶`:
```
s/                                     # Match the following:
      .                                # Match a character in string A
      (?=                              # Lookahead (keep this out of what will
                                       # be replaced)
          (.*$)                        # \1 = capture the rest of string A, to
                                       #      our position
          (?<=                         # Lookbehind - evaluated from right to
                                       # left, so read from the bottom up
              (?=                      # Lookahead - go back to evaluating from
                                       # left to right.
                  (?>                  # Atomic group - after each iteration,
                                       # lock in its match and prevent
                                       # backtracking.
                      .*?              # Skip as few characters as possible,
                                       # minimum zero, to match the following:
                      (.)              # \2 = a character in string A
                      (?=              # Lookahead
                          .*¶          # Skip to the beginning of string T
                          (            # \3 = concatenation of the following:
                              (?>\3?)  # Previous value of \3, if set
                              (\2)     # $4 = the next character in string T
                                       #      (which is capitalized)
                          )
                      )
                  )+                   # Loop the above as many times as
                                       # possible, minimum one, to make the
                                       # following match:
                  \1$                  # Stop at the point we snapshotted,
                                       # making sure that the string ends after
                                       # it, to prevent matching an earlier
                                       # duplicate.
              )
              ^.*                      # First step in the lookbehind - skip
                                       # back to the beginning of the string.
          )
      )
  |                                    # or...
      ¶.*                              # Match the newline and string T, in
                                       # order to erase it.
/                                      # Substitution - replace with this:
$4                                     # The capital letter we captured in $4,
                                       # which will be empty if it was the
                                       # second alternative that matched.
/                                      # Flags:
i                                      # Case Insensitive (so that letters in
                                       # string T will match those captured in
                                       # string A)
m                                      # Multiline - "$" matches the end of any
                                       # line instead of just the end of string.
g                                      # Global - replace all matches instead of
                                       # only the first.
```
# Regex (Python[`regex`](https://bitbucket.org/mrabarnett/mrab-regex/src/hg/) / .NET), 74 bytes
```
s/.(?=(.*$)(?<=(?=(?>.*?(.)(?=.*
(?=(\4?))(\3+(\2))))+\1$)^.*))|
.*/\5/img
```
**[Attempt This Online!](https://ato.pxeger.com/run?1=bVPNTttAEJZ69FMMFpJ3E2MSIC0kmCjQiKYKUAGFIidITrw2i9braNeGhJ9rH6CHXnrh0t76CH0QeuyTdGwToar4NPPt7LffzDf-9mMySy8S-fCLx5NEpaBn2lYsYlP7UieyBcpVpml-z9Jwaf3xvV52SNslTmWRkvamm8ftLafSJg7mrlMxcmSw1qaUDFarZLBC8asO6ov03KlQemc4leVBY5nHUcn4-9VPZPfqzaX60OAhKK82XHAtbTVB-VwzOJrJ1J92lUoUsfa41lxGYGrTokbgKq-8laiABBS4BM1SJ5M8kQQjonwZMbK2bjfWKbWfkY03dn2l8Q_0umFvrCJyW4n9CUFC21wktFJ1Nrfa5ya9py8K6skrX_AAAiZ4zFOmUJYCF5SjJ4KnKCqXJ5gkii64ay9ynKoEW5JZPGIKkvCZSyNZKPxIu7UWjJNMpm7dCBMFYd6p8laHTQOQPnRdK8KBlSU1A5jQrAnFVbhz4dbiVrOw1Ont7h8cdnc6R10brHiO7n3sH_f6vf0c1HPw7cFxp99HZDpHTrqH2wdH3XsvHBoaZ78yLLYDPWjBDb6bSxOFCTPt6DTgEvXBU_-Cgi8DEF6ZoN2oeiBRtnCFVyv8_7-4lleZVs5THN40YaK4TAktkBu33noCBCr98_kLWDYwGbj57jpBFk808Ur1OhuhCzZoLMR3ncuES1KUicQPNLE8qyqq1tDCJShHaZcjpKhiSMsVpeXWPjx-NSW7Qr-iREofIn7FYJZkkE1MG8yT3gfTMH0hIL1gcJ0oEWjwQad-xPLzfmcXz68vZnly-u4Mk5Hvj0ej8Xjk51hnewexaR5-ygP85vGMCZFcA3YT-9g4g5THBelZt3v89Jv-BQ "Python – Attempt This Online") - Python `import regex`**  
[Try it online!](https://tio.run/##lVTbjtMwEH3vV4yMpcTdJrvl8gAllKXahUWshACxoDaAmzqJkWMH29m2lPDIB/CJ/Mgy2UKhEi/MQzSX46Mz44lrsxTWlUKpK2qTh8GVO4zDcRLGfcrC8f2k88cP4v44jDFO4n6vy8xujxkLZ7cOwtlNhnYwG1L2Lu4z9qUX9w/pnUNZFVfBw5HMQ2qnR2mkBXGEbXxpzRKCc@mc1AVgLmjpIkHMML0GL6LCk68kMjacWlGIVRpMj6K7x9Es5VFLQ9Y/iO8/GL9LAxafc5@VwuEhtmM@05dcyQUshJKV9MIiv0X@@GWtpO@gW02xErrwJeqC27vDF9agKN1Uc2HB5H9IXND2qOtk3kxHQItkiN88IRNT1VKJBRnBNCu5naYpYm6lX06NPeFZuXFLiRpD@p5teoAWFAFsaAEJRMN2m5FdJscMoZu8HZwV2lgx4U6QX4BqH3DeKC@V1Lu626@/xMEq8TdA7wNOVjiKTPoJr31jd6jVv3Q85x7b1xclTsHVPNuh7T76hSxK/8o8E7knLVzbDcga500FEWjjwTV1bawXC5ivIRznihcM3Fp7vtoyZvuME2wT1XX3aSXXHe1/MLZ4Xzb5tUH37mmxDK93bEBz1qOfk6NRjt3x7moUSA1U6rrxbNPthur2VXwKSLCNP7PN0mL/UWmcb/HwcPQnhkgbZO/GjcIV/Pj2HWg4MfpSWBxI9NQZZLexFbXC8YW/S6fWVNsimVKVEhZ9NKiDfNAfyIC6AS0YI217RbRAOBRGaw6FvBSwNg00NRkAeX32nPQIVwp8KWBprFo44OA8L0RXf3b8GOvLct0FF0/eYjDnPJvPs2zOu9zxownmVp37pnPQfvtrfBHwl3DNvML5Y3NeVtekb09OXpGf "PowerShell – Try It Online") - .NET
Since mrab-regex supports variable-length lookbehind, the only adaptation necessary in this port was to eliminate the use of nested backreferences. Groups `\4` and `\5` are copied to each other.
# Regex (Perl / PCRE), 86 bytes
```
s/.(?=(.*)
(.)+((?<=(?=^(?>.*?(.)(?=.*
(\5?+(\4))))+\1
.*(?=\2)\4|(?3)).)))|
.*/$2/sig
```
[Try it online!](https://tio.run/##TY/bTsJAEIbv@xSTTZPuQl2ohxsWqAeIhxg10aiEYrOFFWqWFnsQCXLrA/iIvgjOqkTnZme@fw7/zlSm99ZlruDs@vJCgMk6spCNRqeczlQmrMc0o3bcqotmW@DrsSXEj0jYcpbFSQEkSIhYga2hBXkZ5QW2h@6W53pMPRsR/H@8jgqDBtihsAAXAd1oGjUz4hCHLW2J20ZqmI5U@JSnCTh9h9uaOwNHwM9dHHDg8/0DkNghtu/j1KpfH3BzlP9U3kCs8xqnfovyCrMoZ1VK/WYLwQP127ziI8KCVywa7PlVGuwyjGrgWbyCPNhmwe4b9XcY48jfkNbs7Voej9cbH7/@VfJntm@HAxc8F/CvYrVak0S9qAzGaZJIGMcvChZpCeWMuEBuT6@IRaTWUEwUzNNMj3KQkBdyrIx@fnCM@nyyMMXdSQ@LSMphFA2HkTTs4PAI2atJ702CsckXSut0bhxOJXpVUMTT76W9bveGfAE "Perl 5 – Try It Online") - Perl - all test cases  
[Try it online!](https://tio.run/##lVTbbts4EH33V0wJIiIdWbbT7ENXVoxs6@160U0C947IFWiJkpXSlEDKsXPbx/2A/cT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69Pv6BlTiH61PUSnFUlOcCXdZrtG7smZ3MjvEAcylhmgXa1FpmBnEYfl4IG39y8Bjim9WlXbz4-RUslpyny2WaLrn1HTx4CL4La760Bjz_2pdCSrggcLAV16USqC2rDvRVFD3DfXv_AA "PHP - Attempt This Online") - PCRE2 v10.40+ - all test cases  
[Try it on regex101!](https://regex101.com/r/H2drs5/9) - PCRE1/PCRE2 - try it on your own
This is a port of the .NET regex, emulating variable-length lookbehind using recursion with fixed-length lookbehind, but there's an additional challenge. The .NET regex makes a capture inside the lookbehind which is used as the substitution replacement. That is impossible in Perl/PCRE, since all captures made inside a subroutine (recursive or not) are erased upon exiting it.
So to communicate back from the emulated lookbehind, this regex makes a guess (`\3`, captured by `(.)+`) as to what the capital letter in string `t` will be, and then compares that with the capital letter actually matched inside the lookbehind (`(?=\3)\5`). If it's not a match, the regex will backtrack to before the emulated lookbehind, and try capturing a different capital letter from string `t`.
[Answer]
# PHP, 90 bytes
```
function($a,$t,$i=0){foreach(str_split($a)as$c)echo($z=$c^' ')==@$t[$i]?[$z,++$i][0]:$c;};
```
Simply loops through the characters in the string, and outputs the capitalized one when necessary.
This is an anonymous function, so, it has to be given to a variable to be called.
You can try it on here: <https://onlinephp.io/c/61a1c>  
(Contains all test cases in the question.)
---
## How it works?
It uses the fact that [XOR](https://en.wikipedia.org/wiki/Exclusive_or)ing an [ASCII](https://en.wikipedia.org/wiki/ASCII) character with a space, will toggle the 3rd bit, which will change the letter case.  
With this knowledge, I avoid running [`strtoupper($c)`](https://www.php.net/manual/en/function.strtoupper.php), saving me a bunch of bytes.
---
This is useful for checking against the backronym letters, which are in upper case, and to display the upper case letter.  
These are accomplished in `($z=$c^' ')==@$t[$i]`.  
The `@` is there to suppress warnings, which will happen when we exhaust all characters in `$t`.
---
To make the code shorter, I've used `[$z,++$i][0]`, which displays the upper case character and increments `$i`, without the need to make an `if`.  
The (much longer) alternative is the following:
```
if(($z=$c^' ')==@$t[$i]){++$i;echo$z;}else echo$c;
```
---
One edge-case that people may see as an issue, is with spaces.  
However, if you XOR a space with a space, it gives a [null character (`\0`)](https://en.wikipedia.org/wiki/Null_character).  
**Luckily**, a null character is a [truthy value](https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting).
Another possible edge-case, with spaces, comes from the fact that, after the `$t` string is exhausted, the value will be `null`.  
Since the null character is a [truthy value](https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting), and `null` is a [falsy value](https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting), this will never be `true`, which means that I can use [`==`](https://www.php.net/manual/en/language.operators.comparison.php) instead of [`===`](https://www.php.net/manual/en/language.operators.comparison.php), and saves 1 byte.
[Answer]
# [Lua](https://www.lua.org/), 71 bytes
```
a,b=...;j=1;for i=1,#a do x=a[i]-32;if x==b[j]then a[i]=x j=j+1 end end
```
[Try it online!](https://tio.run/##Jc2xTsQwDAbgnaewekui60UqbFd5YGK5N6gyuGnSpoTklLjiEOLZSwODZfmX/TlstDsMiaZh2KkdUSnVr9j1LmXw2LUnginBA2nw@vLy3Ht3DDgOq@bFRqgxPmDF9dyBjVOtXWu3RcM@RRi/2BZRZEiGAjB@/1TYgI9QrvMHsVka1RwfeDjxudNorvVEyGply1uOwBV9YvyzGgqHs1j4TDlMBQgK02wbJ7j9X7i9vjXynn1kUfhoszILZcE0Bqu2eCfzLlhKuf8C "Lua – Try It Online")
Chunk which modifies `a` in place. Mostly equivalent to the Go solution.
[Answer]
# knight, 68 60 bytes
```
;;=aP=bP;=j=i 0W<iLa;O I-32-A=cGa i 1A=dGb j 1c;=j+1j d=i+1i
```
[Try it online!](https://tio.run/##rVltU9tIEv5s/4rBKWyNXxJJcFVblmUKskBRR4CF5PIBfEGWZZisLPskGZYj3F/PdffMSCPb5C53ywfLmnm6p/uZnu4eE/buwvD7G5GE8XISDbJ8IuZv74d1cyQW48pQmD8tohVQKpK7ylAuZhIziaYiiVgcs3ie3NFHvRj9ePbpA3PK16uPl8wtX/@2f8l2y9ejs/fsl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p2CZsEC9A@es58AZc0yw@5PoAaTHCtb3EUrr9vWIrSknot2hrbh2ObUrbZ/4r68eCJokV@COQAkWSwx8xyvDfZRGrYwlc@ihRZyLhD0GT8Abm8zhTppHd1EKMot5EiW5CPAWASd5zh4jdh88RABUihCes1mQLCF8nt7iKHo3RsaBCmIiW8Y5/mhAixcJT0N6JkYvuUKZKVdAVtSjvteR9uuGFLBBBWXT/TyIsTY@gdfJJI4m7LY0@7bQ8ozfZGNmLFI6M0RlvZ5@5wSvKWjbMP2lyIMDCtaVwodJr5IX/WpW3GPm4R@YxwBF@@rXuSaTgD1WaRRpsMuMbIg6bCmpS64r6wBit3yoNkYXNIRDiaE1n8z7bBbNwgWGWcKGt3v/ryvDP8GVoXZla4MvvvJFubL3Ovty1Q0m4/QeqwDcAuHqArq1yc7ypXBPZx5TQWFes0x/6Mum2rBnSqpUUsh/@2/kVQ4y1BTyXqtvoitt7irWL7NudfqnLzK6ty1vMoirVW4zRSokDGoc@RVpI02iBCI6nUJMmvwZ3JO/epmNZsU7ZvYuSuyk2rUj1JDfc/s7Bi3H8srgGx1WxyxA63ekRF08usVZ2Kk0tFeS6BWl3mrJczeVvB1e9AFuIb1Lg/@hIULD8IlbERbNf9EOmb2RCx7iqh0HmyRqEGT8y0l6EKKjTgKsPommASRJ8Ex3mCKBSTGhH5GCMIcy1doOW9hz4ghnr9xiUVlRA6EbVD8kzAKRYLPKgvQu7JLSdhu@P3D8uYrul/jPHssma6rXuJfv4yAIx@MwHAf1/YP3/wY "C (gcc) – Try It Online")
*-8 bytes thanks to Adam for some nice spacing rearrangements*
In my [J answer](https://codegolf.stackexchange.com/a/249849/15469), which required a lot of machinery, I noted:
> 
> It's interesting to contrast how simple it is to solve procedurally -- you need only a single loop and a single register.
> 
> 
> 
Since knight is a very simple procedural language, I thought it would make an interesting juxtaposition.
## how
```
;=j=i 0                     # initialize indices for the two input strings
;
;=aP=bP                     # read the inputs into variables a and b
W<iLa                       # while (i < a.length)...
;O I-32-A=cGa i 1A=dGb j 1  # Take the ascii difference between the chars
                            # a[i] (store it in c) and b[i] (store in d),
                            # and subtract that from 32
c                           # if the difference is not 0, return c (the lowercase)
;=j+1j d                    # if it is 0, return d (the uppercase) and 
                            # increment j
=i+1i                       # increment i in either case
```
[Answer]
# [><>](https://esolangs.org/wiki/Fish), 26 bytes
```
ri\  >~&o!
&:<&o^?=-*48@:$
```
[Try it online!](https://tio.run/##S8sszvj/vygzRkHBrk4tX5FLzcpGLT/O3lZXy8TCwUrl//9IV9eQ/7rFlak5OfnlCsWlSbmJRZl5qQolmbmpAA "><> – Try It Online")
[Answer]
# [Thunno](https://github.com/Thunno/Thunno) `J`, \$ 13 \log\_{256}(96) \approx \$ 10.70 bytes
```
XeDxAJ=?xZTXu
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72sJKM0Ly9_abSSl1LsgqWlJWm6FmsjUl0qHL1s7SuiQiJKIWJQqQX7lcoyC5S4lPJSy1KLFNLz8_ISFdIzy1IVKvNLFUoLlCDKAA)
Port of Steffan's Vyxal answer.
#### Explanation
```
XeDxAJ=?xZTXu  # Implicit input
X              # Store the first input in x
 e             # Map over the second input:
  D            #  Duplicate the character
   xAJ         #  Push the first character of x
      =?       #  If they are equal:
        xZT    #   Push x without its first character
           X   #   And store it back in x
            u  #   Push the character, uppercased
               #  (Otherwise: the character remains on top)
               # The J flag joins it into a string
               # Implicit output
```
]