[Question]
  [
Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one.
For example, computing this with inputs `codegolf.stackexchange.com` and `e` for the character yields:
```
codegolf.stackexchange.com
cdegolf.stackexchange.com
cegolf.stackexchange.com
ceolf.stackexchange.com
celf.stackexchange.com
cef.stackexchange.com
ce.stackexchange.com
cestackexchange.com
cetackexchange.com
ceackexchange.com
ceckexchange.com
cekexchange.com
ceexchange.com
ceechange.com
ceehange.com
ceeange.com
ceenge.com
ceege.com
ceee.com
ceeecom
ceeeom
ceeem
ceee
```
It keeps the first character and all `e`s. All other characters are removed one by one.
Your task is to write a program (or function) that takes two inputs and outputs (or returns) a string that accomplishes this effect.
## Specifications
* You can assume that the string will not contain any newlines.
* The second input will always be one character.
* If the answer is in the form of a function, you may return an array of strings containing each line in the output.
* The output can contain a trailing newline.
## Test Cases
`Test Cases`, `s`:
```
Test Cases
Tst Cases
Ts Cases
TsCases
Tsases
Tsses
Tsss
```
`Make a "Ceeeeeeee" program`, `e`:
```
Make a "Ceeeeeeee" program
Mke a "Ceeeeeeee" program
Me a "Ceeeeeeee" program
Mea "Ceeeeeeee" program
Me "Ceeeeeeee" program
Me"Ceeeeeeee" program
MeCeeeeeeee" program
Meeeeeeeee" program
Meeeeeeeee program
Meeeeeeeeeprogram
Meeeeeeeeerogram
Meeeeeeeeeogram
Meeeeeeeeegram
Meeeeeeeeeram
Meeeeeeeeeam
Meeeeeeeeem
Meeeeeeeee
```
`Hello World!`, `!`:
```
Hello World!
Hllo World!
Hlo World!
Ho World!
H World!
HWorld!
Horld!
Hrld!
Hld!
Hd!
H!
```
`Hello World!`, `z`:
```
Hello World!
Hllo World!
Hlo World!
Ho World!
H World!
HWorld!
Horld!
Hrld!
Hld!
Hd!
H!
H
```
`alphabet`, `a`:
```
alphabet
aphabet
ahabet
aabet
aaet
aat
aa
```
`upperCASE`, `e`:
```
upperCASE
uperCASE
uerCASE
ueCASE
ueASE
ueSE
ueE
ue
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code (in bytes) wins.
  
[Answer]
# Vim, ~~27, 26~~, 25 bytes
```
DJqqYp:s/.\zs[^<C-r>-]<CR>@qq@qD
```
[Try it online!](https://tio.run/nexus/v#@@/iVVgYWWBVrK8XU1UcHSekG8vlUFjoUOjy/38qV3J@Smp6fk6aXnFJYnJ2akVyRmJeeqpecn4uAA "V ‚Äì TIO Nexus")
Input comes in this format:
```
e
codegolf.stackexchange.com
```
My naive first approach is three bytes longer:
```
i:s/.\zs[^<Right>]<Esc>"addqqYp@a@qq@qdd
```
I'm also happy with this answer because it starts with my name.
```
DJqq:t$|s/.\zs[^<C-r>"]<CR>@qq@qD
DJMcMayhem
```
See the similarity? Eh?
Less successful approaches:
```
i:s/.\zs[^<Right>]<Esc>"addqqYp@a@qq@qdd
i:s/.\zs[^<Right>]<CR>@q<Esc>"adkqqYp@aq@qdd
DJ:s/.\zs[^<C-r>"]<CR>uqqYp@:@qq@qdd
DJqq:t.|$s/.\zs[^<C-r>"]<CR>@qq@qdd
```
Explanation:
```
D                                   " Delete everything on this first line
 J                                  " Remove this empty line
  qq                                " Start recording into register 'q'
    Y                               " Yank this line
     p                              " And paste it
      :s/                           " Run a substitute command on the last line in the buffer. Remove:
         .                          "   Any character
          \zs                       "   Move the selection forward (so we don't delete the first one)
             [^<C-r>-]              "   Followed by anything *except* for the character we deleted
                      <CR>          " Run the command
                          @q        " Call register 'q'
                            q       " Stop recording
                             @q     " Run the recursive macro
                               D    " Delete our extra line
```
[Answer]
# [MATL](http://github.com/lmendo/MATL), ~~20~~ 16 bytes
```
y-f1X-"t[]@X@q-(
```
[Try it online!](http://matl.tryitonline.net/#code=eS1mMVgtInRbXUBYQHEtKA&input=J2NvZGVnb2xmLnN0YWNrZXhjaGFuZ2UuY29tJwonZSc) Or verify test cases: [1](http://matl.tryitonline.net/#code=eS1mMVgtInRbXUBYQHEtKA&input=J1Rlc3QgQ2FzZXMnCidzJw), [2](http://matl.tryitonline.net/#code=eS1mMVgtInRbXUBYQHEtKA&input=J01ha2UgYSAiQ2VlZWVlZWVlIiBwcm9ncmFtJwonZSc), [3](http://matl.tryitonline.net/#code=eS1mMVgtInRbXUBYQHEtKA&input=J0hlbGxvIFdvcmxkIScKJyEn), [4](http://matl.tryitonline.net/#code=eS1mMVgtInRbXUBYQHEtKA&input=J0hlbGxvIFdvcmxkIScKJ3on), [5](http://matl.tryitonline.net/#code=eS1mMVgtInRbXUBYQHEtKA&input=J2FscGhhYmV0JwonYSc).
### Bonus
Modified code to *see the string being gradually shrunk* (offline compiler):
```
y-f1X-"tt.3Y.XxD[]@X@q-(].3Y.XxDvx
```
[![enter image description here](https://i.stack.imgur.com/6UNgZ.gif)](https://i.stack.imgur.com/6UNgZ.gif)
Or try it at [MATL Online!](https://matl.io/?code=y-f1X-%22tt.3Y.XxD%5B%5D%40X%40q-%28%5D.3Y.XxDvx&inputs=%27codegolf.stackexchange.com%27%0A%27e%27&version=19.4.0)
## Explanation
```
y        % Implicitly input string and char. Duplicate string onto top
-        % Subtract. Gives nonzero for chars in the input string that are
         % different from the input char
f        % Array of indices of nonzero values
1X-      % Remove 1 from that array. This gives an array of the indices of 
         % chars to be removed from the string
"        % For each
  t      %   Duplicate previous string
  []     %   Push empty array
  @      %   Push index of char to be removed. But this index needs to be 
         %   corrected to account for the fact that previous chars have
         %   already been removed...
  X@q-   %   ... So we correct by subtracting the 0-based iteration index
  (      %   Assign empty array to that position, to remove that char
         % Implicitly end for each
         % Implicitly display
```
[Answer]
# Haskell, 50 bytes
```
w@(a:x)%c|(d,_:y)<-span(==c)x=w:(a:d++y)%c|0<1=[w]
```
Defines a function `(%)` returning a list of strings.
### Explanation
`(%)` is called as `w%c`, with `w` being the input string, and `c` the character to keep. In short, this definition works by separating `w` into the first character (`a`) and the remainder (`x`), splitting `x` at the first occurrence of a character other than `c`, and recursively calling itself with that one character dropped.
```
w@(a:x)%c              -- define (%) with w separated into a and x.
 |(d,_:y)<-span(==c)x  -- split x; bind the string of `c` to d, and the rest
                       -- to _:y, dropping first character and calling the rest y.
  =w:(a:d++y)%c        -- if there was a character to drop, cons w onto the
                       -- sequence gained by recursively calling (%) with that
                       -- character removed (i.e. call with a:d++y).
 |0<1=[w]              -- if nothing needed to be dropped, the result sequence is
                       -- simply the one-element list [w]
```
[Answer]
## [Retina](http://github.com/mbuettner/retina), ~~28~~ 27 bytes
Byte count assumes ISO 8859-1 encoding.
```
;{G*1`
R1r`(?!^|.*¬∂?\1$)(.)
```
[Try it online!](http://retina.tryitonline.net/#code=O3tHKjFgClIxcmAoPyFefC4qwrY_XDEkKSguKQ&input=Y29kZWdvbGYuc3RhY2tleGNoYW5nZS5jb20KZQ)
### Explanation
```
;{G*1`
```
There's a lot of configuration here. The stage itself is really just `G1``, which keeps only the first line, discarding the input character. `*` turns it into a dry run, which means that the result (i.e. the first line of the string) is printed without actually changing the string. `{` tells Retina to run both stages in a loop until the string stops changing and `;` prevents output at the end of the program.
```
R1r`(?!^|.*¬∂?\1$)(.)
```
This discards the first character which a) isn't at the beginning of the input, b) isn't equal to the separate input character.
[Answer]
## [Pip](http://github.com/dloscutoff/pip), ~~22~~ ~~26~~ ~~24~~ 22 bytes
```
Lv+#Paa@oQb?++oPaRA:ox
```
Takes string as first command-line argument, character as second. [Try it online!](http://pip.tryitonline.net/#code=THYrI1BhSWFAb1FiKytvRSBQYVJBOm94&input=&args=VGVzdCBDYXNlcw+cw)
### Explanation
Loops over characters of input; if the character equals the special character, move on to the next one; if not, delete it and print the string.
An ungolfed version (`a`, `b` get cmdline args; `o` starts with a value of `1`, `x` is `""`):
```
P a         Print a
L #a-1      Loop len(a)-1 times:
 I a@o Q b   If a[o] string-eQuals b:
  ++o         Increment o
 E {         Else:
  a RA: o x   In-place in a, Replace char At index o with x (i.e. delete it)
  P a         Print a
 }
```
Golfing tricks:
* The loop header for `L` is only evaluated once, so we can sneak the initial print in there. `#Pa-1` won't work because `P` is low-precedence (it would parse as `#P(a-1)`), but we can rearrange it to `v+#Pa`, using the `v` variable preinitialized to `-1`.
* The `RA:` operator returns the new value of `a`, so we can print that expression instead of having a separate `Pa` statement.
* Now both of the branches of the if statement are single expressions, so we can use the ternary operator `?` instead.
[Answer]
# Perl 5, 29 bytes
I got 35 bytes using Strawberry Perl: 31 bytes, plus 1 for `-nE` instead of `-e`, plus 3 for space + `-i` (used for the single-letter input; the longer string is from STDIN).
```
chomp;say;s/(.)[^$^I]/$1/&&redo
```
However, I've no doubt this is doable without `chomp;` using `<<<`, which is 29 bytes, even though I can't test it myself using Strawberry.
```
say;s/(.)[^$^I]/$1/&&redo
```
Thus:
```
perl -im -nE'say;s/(.)[^$^I]/$1/&&redo' <<< "example"
```
[Answer]
# [Perl 6](https://perl6.org), ~~¬†47 40¬†~~ 38 bytes
```
->\a,\b{a,{S/^(."{b}"*:)./$0/}...^{$^a eq $^b}}
```
```
->\a,\b{a,{S/^(."{b}"*:)./$0/}...^&[eq]}
```
```
{$^b;$^a,{S/^(."$b"*:)./$0/}...^&[eq]}
```
## Expanded:
```
{       # lambda with two placeholder parameters ÔΩ¢$aÔΩ£ and ÔΩ¢$bÔΩ£
  $^b;    # declare second parameter
  $^a,    # declare first parameter, and use it to seed the sequence
  {       # bare block lambda with implicit parameter ÔΩ¢$_ÔΩ£
    S/      # string replace and return
      ^       # beginning of string
      (       # capture into ÔΩ¢$0ÔΩ£
        .       # the first character
        "$b"*   # as many ÔΩ¢$bÔΩ£ as possible
        :       # don't allow backtracking
      )
      .       # any character ( the one to be removed )
    /$0/      # put the captured values back into place
  }
  ...^      # repeat that until: ( and throw away the last value )
  &[eq]     # the infix string equivalence operator/subroutine
}
```
The reason `...^` was used instead of `...` is that `&[eq]` wouldn't return `True` until the last value was repeated.
[Answer]
# [Python 3](https://docs.python.org/3/), 72 bytes
```
def e(i,k):
 for r in i:
  if r!=k:i=i[0]+i[1:].replace(r,'',1);print(i)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/PyU1TSFVI1MnW9OKSyEtv0ihSCEzTyETyFHITFMoUrTNtsq0zYw2iNXOjDa0itUrSi3ISUxO1SjSUVfXMdS0LijKzCvRyNT8n6qh/mH@jO4P85dO/TC/tw9ITwbiiUj0JKB4G5CeAqWB4r2tQHoOVM0UCL@3BSSvrqMOElbX/A8A "Python 3 ‚Äì Try It Online")
```
e('üòãü•ïüçéü•ìü•ëü•ìü•ëü•íüçÜü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ','ü•ì')
```
Go on a diet:
```
üòãü•ïüçéü•ìü•ëü•ìü•ëü•íüçÜü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãüçéü•ìü•ëü•ìü•ëü•íüçÜü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ëü•ìü•ëü•íüçÜü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìü•ëü•íüçÜü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìü•íüçÜü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìüçÜü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìü•îüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìüçÜü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìü•ìüçÖü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìü•ìü•úü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìü•ìü•ìü•îüçÖüçÑüçÜ
üòãü•ìü•ìü•ìü•ìüçÖüçÑüçÜ
üòãü•ìü•ìü•ìü•ìüçÑüçÜ
üòãü•ìü•ìü•ìü•ìüçÜ
üòãü•ìü•ìü•ìü•ì
```
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), ~~26~~ 25 bytes
```
¬¨ÀÜ[¬¶√êg_#¬¨¬≤k0Qi¬≤ÀÜ√´¬ØJ?,]¬ØJ?
¬¨ÀÜ                         Put the first character into an array
  [                        While true
   ¬¶                       Remove the first character
    √ê                      Triplicate
     g_#                   if the string is empty, break
        ¬¨¬≤k0Qi             if the first character is equal to the one specified in the input
              ¬≤ÀÜ           Add it to the array
                √´          Else
                 ¬ØJ?       Display the array
                    ,      Display the remaining string
                     ]     End while
                      ¬ØJ?  Display the last string
```
[Try it online!](http://05ab1e.tryitonline.net/#code=wqzLhlvCpsOQZ18jwqzCsmswUWnCssuGw6vCr0o_LF3Cr0o_&input=TWFrZSBhICJDZWVlZWVlZWUiIHByb2dyYW0KZQ)
Please note that `¬¨¬≤k0Q` could be rewritten `¬¨¬≤Q`, but for some reason it doesn't work when the current character is a quote mark: Q returns the actual string instead of a boolean and it causes an infinite loop.
This code can be golfed further since `¬ØJ?` is duplicated. Moving this part in the loop would remove the duplication and would also allow to drop the closing square bracket.
[Answer]
# Python 2, ~~71~~ 66 bytes:
```
f,m=input();k=f[0]
while f:a=f[0]==m;k+=f[0]*a;f=f[1+a:];print k+f
```
A full program. Takes 2 inputs through STDIN in the format `'<String>','<Char>'`.
Also, here is a recursive solution currently at **140 bytes**:
```
Q=lambda c,p,k='',j=1,l=[]:c and Q(c[1:],p,k+c[0]*(j<2)+c[0]*(c[0]==p),j+1,l+[k+c])or'\n'.join(sorted({*l},key=l.index))+('\n'+k)*(k not in l)
```
This one should be called in the format `print(Q('<String>','<Char>'))`.
[Answer]
## JavaScript (ES6), 74 bytes
```
(s,c)=>[...t=s.slice(1)].map(d=>c!=d?s+=`
`+s[0]+(t=t.replace(d,``)):s)&&s
```
[Answer]
# [V](https://github.com/DJMcMayhem/V), 12 bytes
```
√≤Yp√≥.“„a]√≤d
```
[Try it online!](https://tio.run/nexus/v#@394U2TB4c16hyYfahFKjD28KeX//@T8lNT0/Jw0veKSxOTs1IrkjMS89FS95Pzc/6kA "V ‚Äì TIO Nexus")
Hexdump:
```
00000000: f259 70f3 2e93 8412 615d f264            .Yp.....a].d
```
I have tested this with [the latest version of V available before the challenge](https://github.com/DJMcMayhem/V/tree/439edc84892be237dc65eb408ea3e6ba93ceff4d), and everything runs correctly, making this answer competing.
Explanation:
```
√≤         √≤    " Recursively:
 Yp            "   Duplicate this line
   √≥           "   Remove:
    .a]      "     A compressed regex
            d  " Delete our extra line
```
The compressed regex translates to
```
.\zs[^e]
```
Which means
```
.           " Any character
 \zs        " Leave the previous character out of the selection
    [^e]    " Any character except for 'e' (Or whatever is given for input)
```
**[11 bytes version](https://tio.run/nexus/v#ATAAz///w7LDmcOzLsKTwoQSYV3DsmT//2NvZGVnb2xmLnN0YWNrZXhjaGFuZ2UuY29t/2U)**
This version uses a shortcut for `Yp` that wasn't available when this challenge was posted.
[Answer]
# Ruby, ~~148~~ ~~139~~ ~~97~~ ~~90~~ ~~83~~ ~~77~~ 62 bytes
```
a,c=$*;p s=""+a;i=1;while d=s[i];(d!=c)?(s[i]="";p s):i+=1;end
```
Not sure if amateur code is accepted on this exchange but I'm interested in learning to code golf although I'm terrible at it, any help on how I'd get this program looking as small as the others here?
**EDIT:**
Replaced puts with p
Removed a tonne of whitespace and counted bytes correctly thanks to Wheat Wizard
Thanks to challenger5 went from `s=gets.chop;c=gets.chop;` to `s,c=gets.chop,gets.chop;`
replaced `then` with `;` and `gets.chop` with `gets[0]` thanks Mhutter!
Taking input as command line variables now, eg. `prog.rb helloworld l`
Thanks to numerous improvements by jeroenvisser101 replacing `a=s.dup` with `s=""+a` and the previous if statement `if s[i]!=c;s[i]="";p s;else i+=1;end` with `(d!=c)?(s[i]="";p s):i+=1;` huge improvement!
[Answer]
# c90, 129 125 bytes
with whitespace:
```
main(q, x)
{
    for (char **v = x, *a = v[1], *b = a, *c;*b++;)
        for (c = a; c == a | *c == *v[2] && *b != *v[2] && putchar(*c),
            ++c != b || *b != *v[2] && !puts(b););
}
```
without whitespace:
```
main(q,x){for(char**v=x,*a=v[1],*b=a,*c;*b++;)for(c=a;c==a|*c==*v[2]&&*b!=*v[2]&&putchar(*c),++c!=b||*b!=*v[2]&&!puts(b););}
```
ungolfed:
```
#include <stdio.h>
int main(int argc, char **argv)
{
    char *a = argv[1];
    for (char *b = a + 1; *b; b++) {
        if (*b == *argv[2]) {
            continue;
        }
        putchar(*a);
        for (char *c = a + 1; c != b; c++) {
            if (*c == *argv[2]) {
                putchar(*c);
            }
        }
        puts(b);
    }
}
```
This takes a pointer to the start of the string, and loops, iterating this pointer until it reaches the end of the string. Within the loop, it prints the first character, then any instances of the second argument it finds between the start of the string and the pointer. After this, it calls puts on the pointer, printing out the rest of the string.
This must be compiled on a system where sizeof(int) == sizeof(char\*). +3 bytes otherwise.
This is the first time I've tried code golfing here, so I'm sure there are some optimizations to be made.
[Answer]
# JavaScript (ES6), 63 ~~64 69~~
Thanks to @Shaggy for shaving 1 byte!
Returning a single string with newlines
```
s=>c=>[...s].map((x,i,z)=>i&&x!=c&&(s+=`
`+z.join(z[i]='')))&&s
```
```
F=
s=>c=>[...s].map((x,i,z)=>i&&x!=c&&(s+=`
`+z.join(z[i]='')))&&s
  
function update() {
  var s=S.value,c=C.value[0]
  O.textContent=F(s)(c)
}
update()
```
```
<input id=S value='Hello world!' oninput='update()'>
<input id=C value='!' oninput='update()'>
<pre id=O></pre>
```
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 27 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
`{√ói‚Üê‚äÉ1+‚ç∏‚ç∫‚â†1‚Üì‚éï‚Üê‚çµ:‚ç∫‚àá‚çµ/‚ç®i‚â†‚ç≥‚â¢‚çµ}`
`‚ç∫` is the excluded character, `‚çµ` is the initial string
print argument; find index `i` of the first non-`‚ç∫` after the first char; if found, call recursively with `i` removed
[Answer]
# Mathematica, 64 bytes
```
Most@FixedPointList[StringReplace[#,b_~~Except@a:>b,1]&,a=#2;#]&
```
Anonymous function. Takes two strings as input, and returns a list of strings as output. Works by repeatedly removing the first non-instance of the character.
[Answer]
# PHP, ~~88~~ ~~84~~ ~~86~~ ~~85~~ ~~82~~ ~~81~~ 78 bytes
1 byte saved thanks to @IsmaelMiguel, 3 bytes thanks to @user59178, 3 bytes inspired by @user59178
```
while($b=substr("$argv[1]\n",$i++))$a>""&$b[0]!=$argv[2]?print$a.$b:$a.=$b[0];
```
takes input from command line arguments; run with `php -r <code> '<string>' <character>`
---
* appends a newline to the input for an implicit final print.  
That adds ~~5~~ 4 bytes of code, but saves on the output and an additional `echo$a;`.
[Answer]
# 05AB1E, ~~26~~ ~~24~~ 23 bytes
Thanks @Kade for 2 bytes!  
Thanks @Emigna for 1 byte!
```
¬¨UDvy¬≤k0√äiy¬°¬¨s¬¶y√Ω¬´Xs¬´=¬¶
```
Uses the **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=wqxVRHZ5wrJrMMOKaXnCocKsc8KmecO9wqtYc8KrPcKm&input=TWFrZSBhICJDZWVlZWVlZWUiIHByb2dyYW0KZQ)
`y¬≤k0√ä` could be `y¬≤√ä` but the `"` messes it up.
This probably could be golfed more because `¬´` is repeated twice. Please leave a comment if you have any suggestions or ways to golf it down more.
[Answer]
# Java 10, ~~155~~ ~~140~~ ~~139~~ 124 bytes
```
c->s->{var r=s+"\n";for(int i=0;++i<s.length();)if(s.charAt(i)!=c)r+=(s=s.substring(0,i)+s.substring(i--+1))+"\n";return r;}
```
[Try it online.](https://tio.run/##pZCxbsIwEIZ3nuLIgq0Qi85pIqGoVRcmKnUoHY7ggME4lu@CRBHPnqYlEp1aqnrxyefvP3/e4gGT7WrXlhaJYIbGnQYAxMimhG3XVQ0bq6rGlWxqpx774r7YYMCSdRj/eG3Owbj1GC57nkMFWVsmOSX56YABQkZxtHBRWtVBGMdgskkax@aelNVuzRshU2kqQarsBk5ZGDnMShniTFBGipolfSWLydjI@PuBSZL4TspLetDcBAchPbfpoBP0zdJ2gr3noTYr2Hfu4vLM1zdA@fkPAPMjsd6rumHluxZbJyqF3tujGNFI9mX0rImhQNIUSZn@SuorOcOdBoRFVOh@LSLwoV4H3N@UNbxmPWlra3ipg10Nb2Lf/8HilUXrN7jU/Ff3xnsdiun8oQfPg3P7AQ)
**Explanation:**
```
c->s->{          // Method with character and String parameters and String return-type
  var r=s+"\n";  //  Result-String, starting at the input-String with trailing new-line
  for(int i=0;++i<s.length();)
                 //  Loop over the characters of the String, skipping the first
    if(s.charAt(i)!=c)
                 //   If the current character and the input-character are equal
      r+=(s=s.substring(0,i)+s.substring(i--+1))
                 //     Remove this character from the String `s`
         +"\n";  //     And append the new `s` with trailing new-line to the result-String
  return r;}     //  Return the result-String
```
---
**Old 139 bytes recursive answer:**
```
void c(String s,int c){System.out.println(s);for(int i=1;i<s.length();)if(s.charAt(i++)!=c){c(s.substring(0,i-1)+s.substring(i),c);break;}}
```
-1 bytes thanks to *@Eugene*. (Next time make a comment instead of editing someone else's post, please.)
[Try it online.](https://tio.run/##nY@xbsIwEIZ3nuKSBVsJUZldBoSQujBRqUPpcHFMYjBx5HOQWpRnT50oA0OHqDfef9@v7y54x9WluPbSIBEcUNePBQB59Fr2d6sLkOzona5LoFTXHiR/HL/Jq1tmW581IfGmZsTF2To2HOjNWuhXyoyqS18xLrg@M8pkhW7rmU4SHm1CiQw7anMau9lLqldrnjyvNE8lF7lTeBVd14tF8Gra3Gg56cGodwvKk@HnFyAf9CFIx@@KPOyQFMUpLGnJxZj8IT8lgTngVQHCKd6paU4xNM6WDm9Di5rV8qaMsfBhnSmigYr@Rf3MotA0FebKDwTOItqmUW63Pe6fHuoWXf8L)
**Explanation:**
```
void c(String s,int c){     // Method with String and integer parameters and no return-type
  System.out.println(s);    //  Print the input-String with trailing new-line
  for(int i=1;i<s.length();)//  Loop over the characters of the String, skipping the first
    if(s.charAt(i++)!=c){   //   If the current character and the input-character are equal
      c(s.substring(0,i-1)+s.substring(i),c); 
                            //    Remove this character, and do a recursive call
      break;}}              //    And stop the loop
```
[Answer]
# C#, 122 117 112 bytes
```
IEnumerable F(string s,char c){for(int i=0;i<s.Length;++i)if(i<1||s[i]!=c)yield return i>0?s=s.Remove(i--,1):s;}
```
Ungolfed : 
```
public IEnumerable F(string s, char c) {
    for (int i = 0; i < s.Length; ++i) {
        if (i < 1 || s[i] != c)
            yield return i > 0 ? s = s.Remove(i--, 1) : s;
    }
}
```
Returns a collection of strings.
[Answer]
**TSQL, 127 bytes(Excluding variable definitions)**
```
DECLARE @1 VARCHAR(100)='codegolf.stackexchange.com'
DECLARE @2 CHAR(1) = 'o'
DECLARE @ char=LEFT(@1,1)WHILE patindex('%[^'+@2+']%',@1)>0BEGIN SET @1=STUFF(@1,patindex('%[^'+@2+']%',@1),1,'')PRINT @+@1 END
```
Formatted: 
```
DECLARE @1 VARCHAR(100) = 'codegolf.stackexchange.com'
DECLARE @2 CHAR(1) = 'o'
DECLARE @ CHAR = LEFT(@1, 1)
WHILE patindex('%[^' + @2 + ']%', @1) > 0
BEGIN
    SET @1 = STUFF(@1, patindex('%[^' + @2 + ']%', @1), 1, '')
    PRINT @ + @1
END
```
[Answer]
# C#, ~~135~~ ~~138 :(~~ 137 bytes
Golfed:
```
IEnumerable<string>F(string s,char c){int i=1,l;for(;;){yield return s;l=s.Length;while(i<l&&s[i]==c)i++;if(i==l)break;s=s.Remove(i,1);}}
```
Ungolfed:
```
    IEnumerable<string> F(string s, char c)
    {
        int i = 1, l;
        for (;;)
        {
            yield return s;
            l = s.Length;
            while (i < l && s[i] == c)
                i++;
            if (i == l)
                break;
            s = s.Remove(i, 1);
        }
    }
```
Function returns collection of strings.
EDIT1: @psycho noticed that algorithm was not implemented properly.
EDIT2: Created variable for `s.Length`. One byte saved thanks to @TheLethalCoder.
[Answer]
# **Python 2 - ~~65~~ 73 Bytes**
```
lambda s,c:[s[0]+c*s[1:i].count(c)+s[i+1:]for i in range(len(s))]
```
And a **76 Bytes** recursive solution, because despite being longer than the firt one, I kinda like it better:
```
f=lambda s,c,i=1:s[i:]and[[s]+f(s[:i]+s[i+1:],c,i),f(s,c,i+1)][s[i]==c]or[s]
```
[Answer]
## Racket 194 bytes
```
(let p((s s)(n 1)(t substring)(a string-append))(displayln s)(cond[(>= n(string-length s))""]
[(equal? c(string-ref s n))(p(a(t s 0 n)(t s n))(+ 1 n)t a)][else(p(a(t s 0 n)(t s(+ 1 n)))n t a)]))
```
Ungolfed: 
```
(define (f s c)
  (let loop ((s s)
             (n 1))
    (displayln s)
    (cond
      [(>= n (string-length s))""]
      [(equal? c (string-ref s n))
       (loop (string-append (substring s 0 n) (substring s n))
             (add1 n))]
      [else
       (loop (string-append (substring s 0 n) (substring s (add1 n)))
             n)])))
```
Testing: 
```
(f "Test cases" #\s)
(f "codegolf.stackexchange.com" #\e)
```
Output: 
```
Test cases
Tst cases
Tst cases
Ts cases
Tscases
Tsases
Tsses
Tsses
Tsss
Tsss
""
codegolf.stackexchange.com
cdegolf.stackexchange.com
cegolf.stackexchange.com
cegolf.stackexchange.com
ceolf.stackexchange.com
celf.stackexchange.com
cef.stackexchange.com
ce.stackexchange.com
cestackexchange.com
cetackexchange.com
ceackexchange.com
ceckexchange.com
cekexchange.com
ceexchange.com
ceexchange.com
ceechange.com
ceehange.com
ceeange.com
ceenge.com
ceege.com
ceee.com
ceee.com
ceeecom
ceeeom
ceeem
ceee
""
```
[Answer]
# Swift 3 - ~~151~~ 147 bytes
Swift isn't the ideal language for golfing, particularly when it relates to string indexing. This is the best I could do:
```
func c(a:String,b:String){print(a);var q=Array(a.characters),i=1;while i<q.count{if "\(q[i])" != b{q.remove(at:i);c(a:String(q),b:b);break};i=i+1}}
```
Unfortunately, Swift needs spaces around `!=` (but not for `==`), and Swift 3 dropped the `++` operator. The trick for both of these is to convert to a character array which allows integer indexing, and using string interpolation of a character to convert back to a `String` (`"\(c)"`).
Ungolfed:
```
func c(a:String, b:String) {
    print(a)
    var q = Array(a.characters)
    var i = 1
    while i < q.count {
        if "\(q[i])" != b {
            q.remove(at:i)
            c(a: String(q), b: b)
            break
        }
        i=i+1
    }
}
```
---
### Previous, non-recursive solution
```
func c(a:String,b:String){var q=Array(a.characters),e={q.removeFirst()},z="\(e())";print(a);while !q.isEmpty{"\(e())"==b ? z=z+b : print(z+String(q))}}
```
```
func c(a:String, b:String) {
    var q = Array(a.characters)
    var z = "\(q.removeFirst())"
    print(a)
    while !q.isEmpty {
        if "\(q.removeFirst())" == b {
            z = z + b
        }else{
            print(z + String(q))
        }
    }
}
```
[Answer]
## Pyke, ~~26~~ ~~19~~ 17 bytes
```
jljjhF3<Q/Q*jih>s
```
[Try it here!](http://pyke.catbus.co.uk/?code=jljjhF3%3CQ%2FQ%2ajih%3Es&input=e%0Acodegolf.stackexchange.com)
```
                  - Q = input
j                 - j = input_2
 ljjhF3           - for (i, j, j[0]) for i in range(len(j))
       <          -     j[:i]
        Q/        -    ^.count(Q)
          Q*      -   ^*Q
                s -  sum(j[0], ^, V)
            jih>  -   j[i+1:]
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 77 [bitsv1](https://github.com/Vyxal/Vyncode/blob/main/README.md), 9.625 bytes
```
·∏£‚â¨‚Ä°‚Å∞‚â†«ë‚üá‚Üî·π†+
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=1#WyI9IiwiIiwi4bij4oms4oCh4oGw4omgx5Hin4fihpThuaArIiwiIiwiY29kZWdvbGYuc3RhY2tleGNoYW5nZS5jb21cbmUiXQ==)
## Explained
The very first explanation generated using [Luminespire](https://vyxal.github.io/Luminespire/), a currently work-in-progress explanation formatting assistant. Now with metadata!
```
·∏£‚â¨‚Ä°‚Å∞‚â†«ë‚üá‚Üî·π†+¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå¬≠
·∏£           # ‚Äé‚Å°Push first character of input, then all of input minus first character
 ‚â¨     ‚Üî    # ‚Äé‚Å¢Repeat and collect results of applying the following on the top of the stack until invariant:
  ‚Ä°  «ë      # ‚Äé‚Å£  Find the first index of:
   ‚Å∞‚â†       # ‚Äé‚Å§     a character that isn't the second input
      ‚üá     # ‚Äé‚Å¢‚Å°  Remove that character from the top of the stack
        ·π†   # ‚Äé‚Å¢‚Å¢Convert each item to a string via vectorised summation
         +  # ‚Äé‚Å¢‚Å£Prepend the first letter to each
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 70 bytes
```
f(x,v,i)char*x,*i;{for(puts(i=x);*++i;)*i-v&&puts(x,strcpy(i--,i+1));}
```
[Try it online!](https://tio.run/##Pcy9DoIwFIbhnas4MkBbyuDcMLG4uJk4iENTCzaCJW0hNYRrr/wYz/jleY/IGyFCqJGnI1VYPLkhnhLFplob1A/OIlV4zEiWKYaJysck2VZPrTOi/yCV51RlR4zZHDqu3ghP0foG7O0OBcQXaR2U3Eobs6hGlkJqU8x243Zz5i8JHKq4lL@rYuiNbgzvtsotlfxXw16dZNtquGrTPg6bGhZ1WNUcvg "C (gcc) ‚Äì Try It Online")
# [C (gcc)](https://gcc.gnu.org/), 65 bytes(32-bit) by c--
```
f(x,v){char*i;for(puts(i=x);*++i;)*i-v&&puts(x,strcpy(i--,i+1));}
```
[Try it online!](https://tio.run/##PcwxD4IwEIbh3V9xMmAL7aCODROLi5uJgzo0tcXGIqRXDMbw160Kxhu/PO8pXikVoyE9u9OnukifWWEaT9ouILFFT0WW51bQzPJ7mo5rzzB41T6I5ZzZfEmpGGIt7Y3Q5@z7AvBwggKSncYApUSNiZgZggwWuKBiMmEyW3nVIOGYlPp3xwRa31Re1mMVPpX@V91UbbRzDewb787zUXUfNf@qIb6UcbLCyOv16g0 "C (gcc) ‚Äì Try It Online")
[Answer]
# Mathematica, 78 bytes
Damn you Martin Ender, I was almost first :p
```
(i=2;a={c=#};While[i<=Length@c,If[c[[i]]==#2,i++,c=c~Drop~{i};a=a~Append~c]];a)&
```
Unnamed function; straightforward implementation with a `While` loop and a few temporary variables.
]