I've seen similar questions but none of them seem to help for what I'm trying to do and have spent ages trying to work thru the RE documentation with no luck so far.
I am currently splitting a string
my str = 'a+0b-2a+b-b'
re.split(r'([+-])', my_str)
which gives me the strings and the separators in a list
['a', '+', '0b', '-', '2a', '+', 'b', '-', 'b']
But I'd like the separators, which are + or - to be included in the next string, not as a separate item. So the result should be:
['a', '+0b', '-2a', '+b', '-b']
Appreciate any help