I am trying to understand to get the repeated words based on matching their last 3 characters or three characters from a string.
var1 = "we have hotel in Singapore and we have motel as well in Singapore, please let us know about your plan of visit and we will tell you more about venue and locations around us."
Expected some like below:
Words having their last 3 character same should be returning like.
(hotel, motel, singapore, about, have)
Trial:
when i'm testing that over regex101.com as (\w[a-zA-Z]tel) it gets me the word hotel and motel, Similarly ..
(\w*[a-zA-Z]ore) <-- this gives me `Singapore`
(\w*[a-zA-Z]out) <-- this gives me `about`
(\w*[a-zA-Z]ve) <-- this gives me `have`
(we\s) <-- this gives me `we`
Now, while i am combining them altogether like (\w[a-zA-Z]tel)(\w*[a-zA-Z]ore)(\w*[a-zA-Z]out)(\w*[a-zA-Z]ve)(we\s) it doesn't gives anything.
I am Just trying hard to get it but not getting a right solution.
EDIT:
As i am giving the last three characters hard coded, Is it possible to achieve this without providing these and evaluate the same.
we, you are extracting a known word? Right now, you could as well usere.findall(r'\b(\w*[a-zA-Z](?:ore|out|ve)|we)\b', text)(\w[a-zA-Z]tel)|(\w*[a-zA-Z]ore)|(\w*[a-zA-Z]out)|(\w*[a-zA-Z]ve)|(we\s)set(re.findall(r'\w*[^\W\d_]{3}\b', text))?set([x.group() for x in re.finditer(r'\b[a-zA-Z]*([a-zA-Z]{3})\b(?=.*\1\b)', text)])?