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

I wouldn't do it with a single substitution, but either with two:
s/\b42\b,?// && s/,$//;
or none:
join ",", grep {$_ != 42} split /,/, $string
Perl --((8:>*

Replies are listed 'Best First'.
Re^2: Howto strip 42 from comma separated list using s///
by ady (Deacon) on Nov 03, 2005 at 13:43 UTC
    I'd much prefer one plain vanilla regex (w/o Perl /e magic), so does such a beast exist...?
    /allan
      Just by listing all cases.
      s/,42\b|\b42,|^42$//
      But next time, ask VB questions on a VB forum.
      Perl --((8:>*