x = '1P2VI_R072_PH_INSPECT_VIS_{}_**P018**_DX16DY12SDX8SDY1_2020-07-26_14-53-24.JPG'
I am looking to extract 1P2VI
and P018
1st 5 letters and P016
(after 6th underscore)
I got it by a,b = x[:5] , x[29:33]
but there are data like
'V92EM_R071_PH_INSPECT_VIS_2_**10**_210105_133452.JPG'
So how do I extract character that starts after 6th underscore and ends after 6th underscore
need P018
and 10
for above data using python