if ($string =~ m{(int|char|bool|long)}) { print "found $1\n"; } #### if ($string =~ m{(?:int|char|bool|long)}) { print "found\n"; }