Python Wildcard Search a String or Array

Posted on August 26, 2019 at 12:14 pm

In Python you can use fnmatch to enable wildcard search:

import fnmatch

Wildcard search and array of strings:

lst = ['string1', 'testing', 'football']
if fnmatch.filter(lst, 'th?s'):

Wildcard search a string:

if fnmatch.fnmatch('readme.txt', '*.txt'):

Receive updates via email

Other Posts

Updated Posts