Retina, 43(削除) 43 (削除ここまで) 32 bytes
m(+/(^|¶)^(.)(.*¶)+2円+^1円|^$/+`^ms&m`^.
As`.*^$.*
|""L`^|""Lm`^.
Try it online! Try it online! Edit: Saved 11 bytes thanks to @MartinEnder. Explanation:
m(+
Turn on multiline mode forRepeat while the scriptinput changes. (Sadly, this doesn't apply to the regex option below, which costs me 4 bytes.).
/(^|¶)^(.)(.*¶)+2円+^1円|^$/+`ms&
Repeat while there are...only if one line is empty or two lines that begin with the same character...
^m`^.
Delete...delete the first character of every line.
As`.*^$.*
If there is an empty The repeat therefore stops if either a) all the lines begin with different characters, in which case the condition fails and the input does not get changed, or b) at least one line becomes empty, delete everythingin which case all the characters eventually get deleted, at which point the input stops changing.
|""L`^.
Otherwise collectCollect the first character of every line. (If there was no solution, the above loop will have deleted everything and there will be nothing to collect.)
Retina, 43 bytes
m(/(^|¶)(.)(.*¶)+2円/+`^.
As`.*^$.*
|""L`^.
Try it online! Explanation:
m(
Turn on multiline mode for the script. (Sadly, this doesn't apply to the regex option below, which costs me 4 bytes.)
/(^|¶)(.)(.*¶)+2円/+`
Repeat while there are two lines that begin with the same character.
^.
Delete the first character of every line.
As`.*^$.*
If there is an empty line, delete everything.
|""L`^.
Otherwise collect the first character of every line.
Retina, (削除) 43 (削除ここまで) 32 bytes
+/^(.).+^1円|^$/ms&m`^.
|""Lm`^.
Try it online! Edit: Saved 11 bytes thanks to @MartinEnder. Explanation:
+
Repeat while the input changes...
/^(.).+^1円|^$/ms&
...only if one line is empty or two lines begin with the same character...
m`^.
...delete the first character of every line. The repeat therefore stops if either a) all the lines begin with different characters, in which case the condition fails and the input does not get changed, or b) at least one line becomes empty, in which case all the characters eventually get deleted, at which point the input stops changing.
|""L`^.
Collect the first character of every line. (If there was no solution, the above loop will have deleted everything and there will be nothing to collect.)
Retina, 43 bytes
m(/(^|¶)(.)(.*¶)+2円/+`^.
As`.*^$.*
|""L`^.
Try it online! Explanation:
m(
Turn on multiline mode for the script. (Sadly, this doesn't apply to the regex option below, which costs me 4 bytes.)
/(^|¶)(.)(.*¶)+2円/+`
Repeat while there are two lines that begin with the same character.
^.
Delete the first character of every line.
As`.*^$.*
If there is an empty line, delete everything.
|""L`^.
Otherwise collect the first character of every line.