I'm currently looping through some files (working great) and trying to figure out how to grab the indices of something and see if the word it matches can be found in a provided list.
For example:
I have the following in one of the files:
MYLIST['APPLE'] = 'Granny-Smith'
SOMETHINGELSE['BUILDING'] = 'Tall'
ANOTHERTHING['SPELLING'] = 'bad'
ADDITIONALLY['BERRY'] = 'Rasp'
I have a list of things I am trying to match on:
keywords = ['apple', 'berry', 'grape']
If I use this regex it will find indices okay (but finds them all):
\[(.*?)\]
But I'm trying to expand that regex so it will only find the ones that exist in the list of keywords.
What else do I need to add to the regex in order to accomplish this?