... ... ... $nDateStamp = $month . $day . $year; $filename = '17000_DM161_082511.dat'; if (index($filename,$tDateStamp) != -1) { print "found\n"; # substitute the 082511 with the $nDateStamp # results in '17000_DM161_082411.dat }