View Single Post
  #1  
Old 03.05.2022, 14:07
43535 43535 is offline
Junior Loader
 
Join Date: Aug 2018
Posts: 10
Default REGEX for file extension in Archive Extractor

Hi, attempting to create a REGEX to extract only PDFs

For my test I have a RAR with these files:

Quote:
Mathematical Foundations of Computer Science.epub
Quote:
Mathematical Foundations of Computer Science.pdf
Here are my attempts and results:

.*\.(?!pdf) - matched both
.*[.](?!pdf) - matched both
.*(?!pdf)$ - matched none
^.*(?!pdf)$ - matched none

I read a message from 2019 that says that JD uses Java patterns, shouldn't it work?
forget the line anchors, why does the negative lookahead match both epub and pdf?

Tested with regex101.com (Java 8 flavor), works over there, but not in JD. help me fams..

Edit:

Also, this REGEX works but come on...that's really ugly, would rather use negative lookaheads..

.*\.[^p][^d][^f].?

Last edited by 43535; 03.05.2022 at 14:11.
Reply With Quote