lets say I have a string .
a = '!!!!!!a1@@@@@@a2&&&&&&a3::::'
It naturally splits by: a1,a2 and a3 to
['!!!!!!','@@@@@@','&&&&&&','::::']
I want to use the split function, something like:
>>> a.split('a*')
The * indicates that it doesn't matter what character comes after a. Is there an immediate way to do this?
s = '!!!!!!a1@@@@@@a2&&&&&&a3::::'
import re
print(re.split(r'a[0-9]+', s))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With