$names = "1Petrus2 Joh4an Smit 2johnny99 Julius 789"; while($names =~ /\b(\w*\d+\w*)\b/g){ print "$1\n"; }