if (substr($acct_trtmt_hsty,1,1) =~ m/([789])/) { print "the number is: " . $1; } #### my @numbers = $acct_trtmt_hsty =~ m/'([789])'/g; print join ":", @numbers; #### $acct_trtmt_hsty, =~ s/(')([789])(')/$1 . ($2-4) . $3/eg; # note: many different ways to write this regex