$thestring = "15,130,213"; if ($thestring =~ /(^13,)|(,13,)|(,13$)/) { print "13 is in $thestring"; } else { print "13 is not in $thestring"; }