What you say you want doesn’t quite match what you appear to want, based on your before and after.
In any case, this should work:
go to the find/replace form (Ctrl+H assuming normal keybindings)
set the Search Mode to Regular expression
Find what: (?-i)(?:\b(?:(?:172|12[78])\.|ff?e)\S*,\x20*)|,\x20::1
Replace with: nothing (leave that box empty).
You’ll have to hit the Replace All button twice.
This isn’t really a particularly clever or complex regular expression, although it may appear daunting. Some notes:
the (?-i) makes the regex case-sensitive
the (?: and matching ) are just grouping parentheses that don’t capture
the \b matches a “word border” (that is, the border between a word character and a non-word character)
\S* matches zero or more non-whitespace characters
\x20 matches a normal space character.