JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03.05.2022, 15: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 15:11.
Reply With Quote
  #2  
Old 03.05.2022, 15:37
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

@43535:
You want a regex that filters out everyting except pdf, right?
negative look-behind -> everything that has not .pdf before end of line
Code:
.*(?<!\.pdf)$
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 03.05.2022, 15:56
43535 43535 is offline
Junior Loader
 
Join Date: Aug 2018
Posts: 10
Default

Seems like I need to up my REGEX game...

Thanks Jiaz :)
Reply With Quote
  #4  
Old 03.05.2022, 16:26
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Quote:
Originally Posted by 43535 View Post
Seems like I need to up my REGEX game...
After many many years of playing the regex game, I still have to look up the negative/positive look arounds as I use them so rarly and when I have to, I've always forgot how they work
__________________
JD-Dev & Server-Admin
Reply With Quote
  #5  
Old 04.05.2022, 18:43
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 70,922
Default

I can recommend regex101.com as an online tool to play around with regular expressions
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #6  
Old 04.05.2022, 18:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Quote:
Originally Posted by 43535 View Post
Tested with regex101.com (Java 8 flavor), works over there, but not in JD. help me fams..
@pspzockerscene: He already knows about it
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 04.05.2022, 18:58
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 70,922
Default

__
my bad
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 11:53.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.