in reply to Howto strip 42 from comma separated list using s///

If it's surrounded by commas, leave the second comma (by using lookahead to find it); otherwise, remove it and whichever comma (if any) is adjacent.
s/,42(?=,)|,?\b42\b,?//g;

Caution: Contents may have been coded under pressure.