JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 03.05.2022, 14:07
43535 43535 is offline
Baby Loader
 
Join Date: Aug 2018
Posts: 5
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
  #2  
Old 03.05.2022, 14:37
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,912
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, 14:56
43535 43535 is offline
Baby Loader
 
Join Date: Aug 2018
Posts: 5
Default

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

Thanks Jiaz :)
Reply With Quote
  #4  
Old 03.05.2022, 15:26
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,912
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, 17:43
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 62,604
Default

I can recommend regex101.com as an online tool to play around with regular expressions
__________________
JD Supporter, Plugin Dev. & Community Manager
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?
That's true James
Quote:
Originally Posted by James
Die Leute verstehen einfach nicht dass nur weil man mit einer Waffe auch auf Menschen schießen kann dass ein Schützenver​ein kein Ort für Amoklaufide​en ist
Reply With Quote
  #6  
Old 04.05.2022, 17:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 76,912
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, 17:58
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 62,604
Default

__
my bad
__________________
JD Supporter, Plugin Dev. & Community Manager
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?
That's true James
Quote:
Originally Posted by James
Die Leute verstehen einfach nicht dass nur weil man mit einer Waffe auch auf Menschen schießen kann dass ein Schützenver​ein kein Ort für Amoklaufide​en ist
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 09:30.
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 - 2022, Jelsoft Enterprises Ltd.