How to extract specific string from file name using just "one line" of code? I can do it in two lines (if we consider only lines with extracted and extracted2) but can't figure out if it is possible to do it in one line?
I would like to extract "this" from filename text__text_numberandtext_text_text_this.xlsx
Here is the "2 line" code I have at the moment:
s = "text__text_numberandtext_text_text_this.xlsx"
extracted = '_'.join(s.split('_')[6:7])
extracted2 = '.'.join(extracted.split('.')[:1])
print(extracted2)