Say I have to split multiple strings within a for loop, which is separated with different delimiters. For example, here in the following example, I have .
and -
as delimiters.
I wanna split the strings and use the first part of the string. The example strings look like this,
ASD-2.T-bR.r1-v1_0
VXD.T-bR.r1-v1_0
VSR.T_bR_r1v1.0
SAP-LT_bR_r1v1.0
From the strings I need the string before the first .
and -
delimiters.
I tried using,
for sam, keys in samp_dic.items():
print(lab_key.split('.-',1)[0])
All the strings are values in a dictionary. The expected output is,
ASD
VXD
VSR
SAP
PS: The marked question (Split string with multiple delimiters in Python [duplicate] ) is for strings, my question is based on strings within dictionary