$ perl -wle '$_ = "142,143"; s/(,42|42,|\b42\b)//g; print' 1143