I have a string below which altogether joined by underscores _
that i want to split in such a way to get my desired output.
Below is list string:
>>> a
'cDOT_stv3027_esx_vdi01_07-24-2021_02.00.00.0443'
>>> type(a)
<type 'str'>
Simple rsplit()
operation by 2
which turns it into 3 different list values as shown below, like from the end its time
, date
and then one combine strings ie 'cDOT_stv3027_esx_vdi01'
which i want to split into two parts like 'cDOT'
& 'stv3027_esx_vdi01'
.
>>> a.rsplit("_",2)
['cDOT_stv3027_esx_vdi01', '07-24-2021', '02.00.00.0443']
I am trying below on the first index but then i'll not retain rest of values.
>>> a.rsplit("_",2)[0].split("_",1)
['cDOT', 'stv3027_esx_vdi01']
My desired output should be like below:
['cDOT', 'stv3027_esx_vdi01', '07-24-2021', '02.00.00.0443']