Retina, 45 bytes
A`-
$
,;BliNClyde ,INPiN
N
nky ,
D`\w+ ,
.*;| ,$
The trailing linefeed is significant. Input and output are spacecomma separated.
Try it online!Try it online! (The first line enables a linefeed-separated test suite.)
Explanation
I did not expect to be able to show off Retina's latest addition (deduplication stages) so soon, but it's really helpful for this challenge. :)
Stage 1: Anti-Grep
A`-
Anti-grep stages discard all lines that match the given regex. The regex is just -
and the input is always a single line, so this discards all ghosts if the input contains Pac-Man
.
Stage 2: Substitution
$
,;BliNClyde ,INPiN
This simply appends the fixed string ;BliNClydeINPiN,;BliNClyde,INPiN
. This will be the list of ghosts in the output after some clean-up.
Stage 3: Substitution
N
nky ,
Note that we've written the three *nky
ghosts with an N
in the previous stage (and omitted the spacecomma after them), and we now expand this shorthand, which saves a couple of bytes. There is now a spacecomma after every single ghost, and we've got the input ghosts and list of all ghosts separated by a semicolon.
Stage 3: Deduplication
D`\w+ ,
This is the new part. Deduplication stages find all instances of the given regex and discard all matched substrings which are equal to an earlier matched substring. Note that theThe regex has a trailing space. So thissimply matches all the ghosts, both in the input and in the list of potential outputs. If the input contains a ghost, then the same ghost will be matched again in the second list and is discarded. Otherwise, the ghost is matched for the first time in the second list and kept. So after this, the list after the semicolon is our desired output. All that's left is a bit of clean-up:
Stage 5: Substitution
.*;| ,$
We simply match everything up to the semicolon as well as the spacecomma at the end of the string and remove them.