Retina 0.8.2, 59 bytes
\G\d
$&$'¶$`,$&
+%)`^.+¶
m`^,|\b0+\B
O`
m`^(.+)(¶\1)+$
$1
Try it online! Link includes test cases. Explanation:
\G\d
$&$'¶$`,$&
Create copies of the line with all possible proper prefixes of the first number on the line.
^.+¶
If there were any such prefixes, delete the original line.
+%)`
Repeat until no more prefixes can be generated.
m`^,|\b0+\B
Remove the leading separator and also leading zeros of any numbers.
O`
m`^(.+)(¶\1)+$
$1
Sort and deduplicate the results.
For the Retina 1 port, the biggest saving comes from deduplication, which is basically a built-in in Retina 1. The newlines aren't included in the deduplication, so another stage is needed to filter out blank lines, but it's still a saving of 14 bytes. Another 3 bytes can be saved by using $"
which is a shorthand for $'¶$`
. I also tried using an L
stage to avoid leaving the original line but then a conditional is required to end the loop which means that the byte count ends up unchanged.