in reply to Re: Howto strip 42 from comma separated list using s///
in thread Howto strip 42 from comma separated list using s///
s/(,42|42,|\b42\b)//g;Tricky, isn't? Unfortunally, you still haven't cover all cases correctly:
You need to anchor all cases:$ perl -wle '$_ = "142,143"; s/(,42|42,|\b42\b)//g; print' 1143
s/,42\b|\b42,|^42$//; # Or s/\b(?:,42|42,|42)\b//; # Or s/\b42,|,?42\b//;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Howto strip 42 from comma separated list using s///
by jbware (Chaplain) on Nov 03, 2005 at 14:21 UTC |