JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04.09.2018, 17:19
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default Extract a path from any code

Extract a path from any code

It does not work with me.
^"[^"]*","(Q:\\AK\s(.*)[^"]*)"

U:\AK.csv(17582306): "y_ddc1d451.jpg","Q:\AK Rysunki ALL!!\-3084290_46842073","117 KB","08-05-13 23:57:00"
Reply With Quote
  #2  
Old 04.09.2018, 19:13
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

this pattern works fine
Code:
^"[^"]*","(Q:\\AK[^"]*)"
tested in regex101
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 04.09.2018, 19:14
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Quote:
Originally Posted by djmakinera View Post
(.*)[^"]*
this is wrong. .* -> everything
[^"]* everything except ", but your everything (.*) will *eat* all
__________________
JD-Dev & Server-Admin
Reply With Quote
  #4  
Old 04.09.2018, 19:29
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

I have only two engines to choose from
Boost.Regex, Onigmo

It really does not work:

Code:
Info:
Cannot find ^"[^"]*","(Q:\\AK[^"]*)"
Reply With Quote
  #5  
Old 04.09.2018, 19:33
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

Not work for me screenshot:
https://s33.postimg.cc/4iqrz4zkv/Scr...t_06.33_PM.jpg
Reply With Quote
  #6  
Old 04.09.2018, 19:36
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Quote:
Originally Posted by Jiaz View Post
this pattern works fine
Code:
^"[^"]*","(Q:\\AK[^"]*)"
tested in regex101
works fine with
Code:
"y_ddc1d451.jpg","Q:\AK Rysunki ALL!!\-3084290_46842073","117 KB","08-05-13 23:57:00"
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 04.09.2018, 19:36
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

@Jiaz - Your regex is invalid - it does not match complex folder names (path)
Reply With Quote
  #8  
Old 04.09.2018, 19:37
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

@Jiaz - But I gave another example line, it's completely different!
Reply With Quote
  #9  
Old 04.09.2018, 19:39
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

1. you gave another example, so it does not work correctly
2. I want to extract only the folder name, not the whole code name.
Reply With Quote
  #10  
Old 04.09.2018, 19:41
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

Quote:
works fine with
Kod:
"y_ddc1d451.jpg","Q:\AK Rysunki ALL!!\-3084290_46842073","117 KB","08-05-13 23:57:00"
I know, But I want to specifically extract just the folder name and nothing else!
Space must be kept, do not combine other names
Reply With Quote
  #11  
Old 04.09.2018, 19:46
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

Example:
Step 1:
Code:
U:\AK.csv(17582306): "y_ddc1d451.jpg","Q:\AK Rysunki ALL!!\-3084290_46842073","117 KB","08-05-13 23:57:00"
Step 2:
I want Extract Path Foldername
Code:
Q:\AK Rysunki ALL!!
Reply With Quote
  #12  
Old 04.09.2018, 19:50
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Your pattern began with ^" so I though your example starts with the actual line
__________________
JD-Dev & Server-Admin
Reply With Quote
  #13  
Old 04.09.2018, 19:53
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Code:
.*"[^"]*","(Q:\\AK([^"]*\\)*)
on
Code:
U:\AK.csv(17582306): "y_ddc1d451.jpg","Q:\AK Rysunki ALL!!\-3084290_46842073","117 KB","08-05-13 23:57:00"
results in
Code:
Q:\AK Rysunki ALL!!\
__________________
JD-Dev & Server-Admin
Reply With Quote
  #14  
Old 04.09.2018, 20:07
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

This modified regex is still invalid because it does not include spaces and any other name always with one space

(Q:\\AK[^"]*)
It matches folder+subfolders here, and I just want ONLY folder name
Reply With Quote
  #15  
Old 04.09.2018, 20:18
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

I don't understand what you want but you should easily be able to modify to your needs.
It returns the full path if you don't want the full path, then modify the pattern
__________________
JD-Dev & Server-Admin
Reply With Quote
  #16  
Old 04.09.2018, 20:24
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

but what regular expression after \s ???
Reply With Quote
  #17  
Old 04.09.2018, 20:27
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

What exactly from
Code:
Q:\AK Rysunki ALL!!\-3084290_46842073
do you want?
1.) Q:\AK Rysunki ALL!!
2.) AK Rysunki ALL!!
3.) Rysunki ALL!!
4.) Rysunki
5.) ???
__________________
JD-Dev & Server-Admin
Reply With Quote
  #18  
Old 04.09.2018, 20:38
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

1.) Q:\AK Rysunki ALL!! (yes)
1.) Q:\AKRysunki ALL!! (no)


Each folder always starts name "AK "
the folder name can contain numbers, letters, various characters, and russian unicode
Reply With Quote
  #19  
Old 04.09.2018, 20:41
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Code:
.*"[^"]*","(Q:\\AK\s+([^"]*\\)*)
requires minimum one space between AK and the rest
__________________
JD-Dev & Server-Admin
Reply With Quote
  #20  
Old 04.09.2018, 21:36
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

Quote:
Originally Posted by Jiaz View Post
Code:
.*"[^"]*","(Q:\\AK\s+([^"]*\\)*)
requires minimum one space between AK and the rest
I do not know why, but it still does not work. Maybe too many different names in many lines.
Please, give me only for the name of the folder, it should work properly then.

Screenshot:
https://s33.postimg.cc/3nco2kyu7/Scr...t_08.34_PM.jpg
Reply With Quote
  #21  
Old 05.09.2018, 11:23
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Works fine in Regex101 with multiple example lines
Maybe your tool/editor you have to escape the ", I don't know. The pattern is correct and working , you can easily validate with regex101 for yourself
__________________
JD-Dev & Server-Admin
Reply With Quote
  #22  
Old 05.09.2018, 11:37
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

shows the group on regex101.com, but I want to extract specific text in the Text Editor, it can not be extracted in a web browser due to the limitations of computing speed, power and memory.

The result is completely different than I expect


Working but (!) -> I only want folder names, not this result:
Wrong Match 1:
U:\AK.csv(17582306): "y_ddc1d451.jpg","Q:\AK Rysunki ALL!!\
Reply With Quote
  #23  
Old 05.09.2018, 11:55
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

regular expression syntax is based on Perl regular expression syntax.

Literals
All characters are literals except: ".", "*", "?", "+", "(", ")", "{", "}", "[", "]", "^", "$", "|", and "". These characters are literals when preceded by a "". A literal is a character that matches itself. For example, searching for "\?" will match every "?" in the document, or searching for "Hello" will match every "Hello" in the document.



Wrong regex [C-Z]:\\IX\s., does not match the full folder name
[/I]
is:
X:\IX 1

shouldbe:
X:\IX 123 56\

Perl Regex engine
Reply With Quote
  #24  
Old 05.09.2018, 12:15
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

My regex should work now:

Code:
[Q-Z]:\\AK\s.+\\
Reply With Quote
  #25  
Old 05.09.2018, 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 djmakinera View Post
Wrong regex [C-Z]:\\IX\s., does not match the full folder name
X:\IX 1

shouldbe:
X:\IX 123 56\
Of course this pattern doesn't match because \s =ONE whitespace/tab...
and the next one is . = ONE any, just ONE.
That's why the pattern returns
X:\IX(one whitespace)(one any)
__________________
JD-Dev & Server-Admin
Reply With Quote
  #26  
Old 05.09.2018, 17:11
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

regex finds Russian words, but not Chinese. Probably need to set a simplified language and a traditional language. Do you know the letters?

Q:\AK Русь\
Q:\AK 是漢藏語系漢語族下之\

[Q-Z]:\\AK\s.+[А-Яа-я诶-贼德]\\
Reply With Quote
  #27  
Old 05.09.2018, 17:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Your tool must support unicode for regex! The pattern stays the same and is correct and works fine on regex101 for
Q:\AK Русь\
Q:\AK 是漢藏語系漢語族下之\
__________________
JD-Dev & Server-Admin
Reply With Quote
  #28  
Old 05.09.2018, 17:53
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

EmEditor - The text editor supports powerful macros, Unicode!
The Japanese production tool supports 100% Unicode Chinese, Japanese, Korean, more...
just need to add a range of letters and it should detect, I just do not know the additional range of the alphabet. I was looking for google, but I found too little information about the alphabet.

Edit by Jiaz:
you don't have to copy/paste pattern explanation!

Last edited by Jiaz; 05.09.2018 at 18:14.
Reply With Quote
  #29  
Old 05.09.2018, 17:57
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

[Q-Z]:\\AK\s.+[Ğ-Яа-Ñ诶-贼月-ä¹™]\\

[Window Title]
EmEditor

[Main Instruction]
The regular expression contains an invalid character class name.

[Content]
[Q-Z]:\\AK\s.+[Ğ-Яа-Ñ诶-贼月-ä¹™]\\

[OK]
Reply With Quote
  #30  
Old 05.09.2018, 18:16
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

You don't have to specify them all in bracket!
[Q-Z]:\\AK\s.+\\
works fine with all your examples!
if those doesn't work with your editor, then you should find out why not. The pattern is correct as you can validate on regex101
__________________
JD-Dev & Server-Admin
Reply With Quote
  #31  
Old 05.09.2018, 21:04
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

It is not easy to determine - what should be the exact pattern for the specific finding of Norwegian, Japanese, Chinese, German and many, many others in the name of the folders.
Reply With Quote
  #32  
Old 06.09.2018, 12:36
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Why not? You want the path and therefore you don't have to care about language?! The given pattern returns the path despite of used language. Don't understand what your problem is?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #33  
Old 06.09.2018, 14:42
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,611
Default

sigh...
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #34  
Old 06.09.2018, 18:38
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

For a really complicated name I want to find, I need to take care of the language of the country. Without it or roses, there are many such complicated requests on forums, but in most cases without solving the problem.
If it's so simple and there are solutions on other forums, I would not ask here.
Reply With Quote
  #35  
Old 07.09.2018, 11:45
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Your initial question was about a pattern that extracts the folder. Not about finding only *specific* folders. Now you come up with another question.......
__________________
JD-Dev & Server-Admin
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 23:00.
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.