Start with your significant character – let’s go for $
, since it’s ASCII 36:
++++++[->++++++<]>
Read input, copying both the input and the significant character over twice, with the second significant character at the end:
[[->+>>>>+<<<<<]>>,[->+>+<<]
for a structure like this:
┌───┲━━━━━━━┱───────┬───────┬───┐
│ $ ┃ blank ┃ input │ input │ $ │
└───┺━━━━━━━┹───────┴───────┴───┘
Subtract the first $
from the first input
:
<[->>-<<]>>
If it’s not zero, move forwards three times to the empty cell after the copy of $
, then move backwards unconditionally, exiting the loop when the input was $
and otherwise leaving you at a $
, ready to start again:
[>>>]<]
After the loop, you’re left on the blank
of the matched character. Move forwards to the matching input character and erase it so it isn’t reprinted, move backwards five times to reach the second-to-last input
’s intact copy, and keep backing up from there (this doesn’t have to rely on wrapping interpreters and such if you shift forwards a bit at the start):
>>[-]<<<<<[<<<<<]
And then print them out!
>>>>>[.>>>>>]
In all,
++++++[->++++++<]>
[[->+>>>>+<<<<<]>>,[->+>+<<]<[->>-<<]>>[>>>]<]
>>[-]<<<<<[<<<<<]>>>>>[.>>>>>]