p = "\home\gef\Documents\abc_this_word_dfg.gz.tar"
I'm looking for a way to retrieve this_word
.
base = os.path.basename(p)
base1 = base.replace("abc_","")
base1.replace("_dfg.gz.tar","")
this works, but it's not ideal because I would need to know in advance what strings I want to remove. Maybe a regex
would be appropriate here?