Q:

Python regex to get string in front of hyphen and plus signs

I have a string as shown in the code. I want to get the final result as: ['AA', 'BB','CC'].
But what I have got here is ['AA', 'BB']. Could you please give me some suggestion? Thank you.
s = "AA-ZZ, BB+ZZ, CC"
a =  re.findall(r'(\w+)[-|\\+\\]\w',s)

A:

Use lookahead to see whether the string is in front of +, - or at the end of string.
a =  re.findall(r'(\w+)(?=[-+]|$)',s)

