0

Regex expression issue

Hi! I'm trying to create a regex expression for the following string: #define AC0_BAP_NR_START #define AC0_BAP_NR_DS_START for match only the first expression. I find this pattern - > (. *) #define AC([0-3] )_BAP_(.*)_START but it's matched the both of the strings. Unfortunately, I didn't find the right expression to exclude the DS for the pattern and I need some help from you, guys. I know I may ask too much but it's really annoying me. I apreciate your help!

18th Sep 2020, 6:53 AM
Dorina Eftimie
Dorina Eftimie - avatar
2 Respuestas
+ 1
Didn't test it but try this: /#define AC[0-3]_BAP_([A-Z]{2})_([A-Z]{2}_)?START/ just read the question again and if I understood well, you don't want the second line to match. Then you could try #define AC[0-3]_BAP_([A-Z]{2})_START
18th Sep 2020, 7:00 AM
CHMD
CHMD - avatar
0
Does this work? m = re.match(r".*#define\s*AC[0-3]_BAP_\w{2}_START", t1) print(m)
18th Sep 2020, 7:11 AM
Bagon
Bagon - avatar