Say I have a dictionary of sets of paths:
my_dict['some_key'] = {'abc/hi/you','xyz/hi/you','jkl/hi/you'}
I want to see if a path appears is in this set. If I have the whole path I simply would do the following:
str = 'abc/hi/you'
if str in my_dict['some_key']:
print(str)
But what if I don't know b is what comes in between a and c. What if it could be literally anything. If I was lsing in a shell I'd just put * and call it a day.
What I want to be able to do is have str be a regx:
regx = '^a.*c/hi/you$' #just assume this is the ideal regex. Doesn't really matter.
if regx in my_dict['some_key']:
print('abc/hi/you') #print the actual path, not the regx
What is a clean and fast way to implement something like this?