简体   繁体   中英

Find the pattern inside the file name in python

I have the database with the specific names. I need to iterate the database records and find the records which have the appropriate pattern. For example: Pattern with wildcard: abc.*.cde File name: abc.123.cde

How can I check that the name "abc.123.cde" is a part of the pattern "abc.*.cde" ?

Seems I have to use the fnmatch module:

fnmatch.fnmatch(files, 'abc.*.cde')

Will return me the files according to the pattern.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM