You are building a file search tool. You are given a list of file names and a search pattern that may include wildcards, return all file names that match the pattern exactly.
'?' matches any single character.'*' matches any sequence of characters (including an empty sequence).Your task is to implement a function that takes a list of file names and a pattern, and returns a list of all file names that precisely match the given pattern according to the wildcard rules.
files = ["readme.md", "eport.pdf", "resume.doc"]
pattern = "r*.?d"
["readme.md"]
The pattern "r*.?d" matches "readme.md": 'r' matches 'r', '*' matches "eadme", '.' matches '.', '?' matches 'm', and 'd' matches 'd'.
files = ["abc.txt", "ab.txt", "a.txt", "x.txt", "a.csv"]
pattern = "a*.txt"
["abc.txt", "ab.txt", "a.txt"]
The pattern "a*.txt" matches any file name starting with 'a', followed by any sequence of characters, and ending with ".txt".
files = ["photo.jpg", "document.pdf", "image.png", "archive"]
pattern = "*.*"
["photo.jpg", "document.pdf", "image.png"]
The pattern "." matches any file name that contains at least one character followed by a dot and then any characters, effectively matching files with an extension. "archive" does not have a dot.
files = ["readme.md", "eport.pdf", "resume.doc"]
pattern = "r*.?d"
["readme.md"]