Lets say that I have a list
list = ['this','is','just','a','test']
how can I have a user do a wildcard search?
Search Word: 'th_s'
Would return 'this'
Use fnmatch:
fnmatch
import fnmatch lst = ['this','is','just','a','test'] filtered = fnmatch.filter(lst, 'th?s')
If you want to allow _ as a wildcard, just replace all underscores with '?' (for one character) or * (for multiple characters).
_
'?'
*
If you want your users to use even more powerful filtering options, consider allowing them to use regular expressions.
1.4m articles
1.4m replys
5 comments
56.9k users