in reply to glob and regex

I want to get files with a specific name format from a directory using glob.

Adding to the recommendation to use opendir/readdir, I'm wondering if by "specific" name format you meant filenames that include the pattern you've given us, or filenames that are matched in their entirety by that pattern. If the latter, then you'll need to add anchors, as follows:

/^[A-Za-z]{2}_\w{2,5}$/ ^ ^