I am new to pandas and need help with an regex expression. I want to extract all the words starting with AA and ending with AA in a column of a dataframe.
I've used the following piece of code.
def getAA(text):
text = str(text)
result = re.findall(r'(AA).*?(AA)',text)
return [result]
df['col']= df['col1'].apply(lambda x: getAA(x))
But I don't get the entire word , when i run it.
I'm expecting something like ['AAhelloAA','AAbyeAA']
I get the result as ['AA','AA'].
Can someone please help me with this?