79780004

Date: 2025-10-01 11:59:26
Score: 1.5
Natty:
Report link

You didn't specify the environement, but I think that it is safe to assume that you have regex on hand. Thus - also assuming that expected extensions are from a finite set - I would create a list of possible extensions and use regex to separate names from extensions.

On this sample set we have tar, tar.gz and zip extensions.

first.tar
second.file.tar
third.tar.gz
fourth.zip
fifth.stuff.zip

Using this Python regex '^(.*)\.(tar|tar\.gz|zip)$'gim you can have the file name in the first capture group and the extension in the second. When you process one filename at once, then m switch (multiline) can be omitted.

Is that something you wanted?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: Trifo