How can the regular expression pattern in the preg_match function be modified to allow for filenames with numbers?

The regular expression pattern in the preg_match function can be modified to allow for filenames with numbers by including the \d metacharacter, which matches any digit from 0 to 9. This will ensure that filenames containing numbers will also be matched by the pattern.

$filename = "file123.txt";

if (preg_match('/^[a-zA-Z0-9_]+\.[a-zA-Z]{3}$/', $filename)) {
    echo "Filename is valid.";
} else {
    echo "Filename is not valid.";
}