How can I remove the third _
and all strings before and also the 4th _
and all string after that using Python Replace method
st = "the_gis_osm_natural_a_free_1.shp"
How can I remove the third _
and all strings before and also the 4th _
and all string after that using Python Replace method
st = "the_gis_osm_natural_a_free_1.shp"
You could split the string by _
and then join the result:
start, end = 3, 4
filename = "the_gis_osm_natural_a_free_1.shp"
print('_'.join(filename.split("_")[start:end]))
Output
natural