I have strings that look alike as below:
ART-B-C-ART0015-D-E01
ADC-B-C-ADC00112-V-E01
AEE-B-C-AEE00011-D-E01
AQW-B-C-AQW0013-D-E01
AAZ-B-C-AAZ0014-D-E01
AQQ-B-C-AQQ0032-D-E01
ADD-B-C-D-ADD0001-D-E01
AAA-B-C-AAA0012-D-E01
I want to have the below result: Expected Result:
ART0015
ADC00112
AEE00011
AQW0013
AAZ0014
AQQ0032
ADD0001
AAA0012
I used the below regex code and unfortunately, I don't get the expected result, due to the 7th record is not in the third dash. it is in the fourth dash.
df["A"].str.extract(r'^(?:[^-]*-){3}\s*([^-]+)', expand=False)
0 ART0015
1 ADC00112
2 AEE00011
3 AQW0013
4 AAZ0014
5 AQQ0032
6 D
7 AAA0012