I'm looking to find the words containing any of the following sequences: 'tion', 'ex' 'ph' 'ost', 'ist', 'ast'.
Here is my function so far:
def latin_ish_words(text):
return re.findall('tion|ex|ph|ost|ist|ast+\b', text, re.I))
However, this is only returning the specific sequence rather than the full words.
Example 1: latin_ish_words("This functions as expected")
returns ['tion', 'ex'], whereas I am looking for ["functions", "expected"].
Example 2: text = 'Philosophy ex nihilo existed in the past' returns ['Ph', 'ph', 'ex', 'ex'], whereas I am looking for ['Philosophy', 'ex', 'existed', 'past']
Looking at the official Re documentation, I thought '\b' returned the full word?
Any suggestions?