if ($input=~$regex) { print "It matches!\n"; } # or while ($input=~/($regex)/g) { print "Found string: $1\n"; }