I have a .txt file of a book and I have a list of words called preposiciones in which every word appears in te .txt file.
Preposiciones = ['a', 'ante', 'bajo', 'cabe', 'con', 'contra', 'de', 'desde', 'durante','en', 'entre', 'hacia', 'hasta', 'mediante', 'para', 'por', 'según', 'sin', 'so', 'sobre', 'tras', 'versus', 'vía'].
I want to find these words in a .txt file.
An easy approach of the solution is the one below. However I´m not allowed to use it so I have to work my way through another code.
re.findall(r'\ba\b|\bante\b|\bbajo\b|\bcabe\b|\bcon\b|\bcontra\b|\bde\b|\bdesde\b|\bdurante\b|\ben\b|\bentre\b|\bhacia\b|\bhasta\b|\bmediante\b|\bpara\b|\bpor\b|\bsegún\b|\bsin\b|\bso\b|\bsobre\b|\btras\b|\bversus\b|\bvía\b', q, flags=re.IGNORECASE)
I tried with this one:
for prep in preposiciones:
re.findall(r'\bf'{prep}'\b', q, flags=re.IGNORECASE)
However I don´t know if it's possible to use a f-string in a re.findall method.
If someone could shed some light on this matter I would appreciate it.