I am trying to write a regular expression to select all characters between underscores. I end up with _([^_]+)_ but it does not match all the groups,
String : abc_bca_vag_hag_bag
output : bca vag hag
can someone help with this?
I used split function and select every elements except first one and last one:
st = 'abc_bca_vag_hag_bag'
lis = st.split('_')[1:-1]
# output ['bca', 'vag', 'hag']
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