I have a dataframe column as follows:
df['col1']
['cat-dog asd-pwr sdf', 'cat-goat asd-pwr2 sdf', 'cat asd-pwr3 sdf']
I need to extract the following:
['asd-pwr', 'asd-pwr2', 'asd-pwr3']
i.e the last pair of substrings which are connected by -
I tried the following:
import re
df['col1'].str.extract(r'\s[a-zA-Z]*-[a-zA-Z]*\s', flags=re.IGNORECASE)
First of all, my regex construct even fails to spot any pair of substrings as desired.