Regex to find all lines (paths)

General discussion related to "Everything".
Post Reply
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Regex to find all lines (paths)

Post by Debugger »

Regex to find all lines (paths)

Drive Letter:

Code: Select all

Q,Z
Example:

Code: Select all

"Q:\Folder\Subfolder"
"Z:\Folder\Subfolder"
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Regex to find all lines (paths)

Post by therube »

I might not be understanding, but...

folder:Q: | folder:Z:
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

a folder/subfolder is just a sample name, but the name contains Russian letters and any other names!
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Regex to find all lines (paths)

Post by Stamimail »

Debugger wrote:a folder/subfolder is just a sample name, but the name contains Russian letters and any other names!
You probably won't need a Regex for this.
Try:
Q:\ | Z:\

or (to get only folders):
folder:Q:\ | folder:Z:\
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex to find all lines (paths)

Post by void »

Is Folder\Subfolder the same for both drives?

Would the following regex search help:
[QZ]:\\Folder\\Subfolder\\
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

I need to match only specific names, so a regular expression is necessary for countless similar names.
The beginning of the all folder name is "AB" followed by a space, followed by other names, numbers, or Russian letters.
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Regex to find all lines (paths)

Post by Stamimail »

If you still need help, try to paste here some real examples.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

X:\AB етний
X:\AB етний 34
X:\AB етний 5 HHH
Z:\AB Miśki
Z:\AB stica 3 (new)
Z:\AB Karaiby & Plaża
Z:\AB Karaiby & Plaża-
froggie
Posts: 301
Joined: Wed Jun 12, 2013 10:43 pm

Re: Regex to find all lines (paths)

Post by froggie »

Code: Select all

startwith:"AB "
match path not checked
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

froggie wrote:

Code: Select all

startwith:"AB "
match path not checked
This is not a regular expression!!! :x
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex to find all lines (paths)

Post by void »

Does the following regex search help:
regex:":\\AB "

or, search X: and Z: only:

regex:"[XZ]:\\AB "

or, with regex enabled from the Search menu, please try searching for:

Code: Select all

:\\AB 
Please make sure there is a space after AB.

or, search X: and Z: only:

Code: Select all

[XZ]:\\AB 
Please make sure there is a space after AB.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

This is too simple a regex that does not work in CSV files (cells). I use EmEditor.
I need a valid Regex, which is found path only in the second cell.
U:\AB.csv(17582306): "y_ddc1d451.jpg","Q:\AB Rysunki ALL!!\-32084290_146842073","117 KB","08-05-13 23:57:00"

search only green (2 cell)

Red - any combination of characters
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex to find all lines (paths)

Post by void »

With regex enabled, please try searching for:
^"[^"]*?","Q:\\AB Rysunki ALL!!

^ = start of line
" = match a single quote.
[^"]*? = lazily (matches on the first occurrence) match any character except ".
" = match a single quote.
, = match comma
" = match a single quote.
Put any text you would like to match in the second column.

Note: This will only work if column one and two are double quoted.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

void wrote:With regex enabled, please try searching for:
^"[^"]*?","Q:\\AB Rysunki ALL!!

^ = start of line
" = match a single quote.
[^"]*? = lazily (matches on the first occurrence) match any character except ".
" = match a single quote.
, = match comma
" = match a single quote.
Put any text you would like to match in the second column.

Note: This will only work if column one and two are double quoted.

It does not work! Regex is invalid. Once on another forum I had a completely different regex and it worked properly, your regex wrong.

Emeditor: Info: Cannot find ^"[^]*?","Q:\\AB


The name of the folder any and the name of the subfolders is:
(\d+)
-(\d+)
(\d+)_(\d+)
-(\d+)_(\d+)

Example:
U:\AB PATH JPG.csv(17359702): "y_6faf5837.jpg","Q:\AB Rysunki ALL!!\-14533360_139830958","104 KB","09-05-13 01:59:55"

Code: Select all

[Window Title]
EmEditor

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

[Content]
^"[^]*?","[E-Z]:\\AB\s.+\\(\d+_\d+)"

[OK]
But I want to extract only the folder names:


However, I solved this problem by partially removing unnecessary cells.
Now how to delete the names of the line subfolders:
Drive Letter:\X\Y

X ANY NAME (NOT DELETE)
Y DELETE EVERYTHING
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

2Debugger
It does not work! Regex is invalid.
Emeditor: Info: Cannot find ^"[^]*?","Q:\\AB
RegEx_Search_Path_in line.png
RegEx_Search_Path_in line.png (59.28 KiB) Viewed 21828 times
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

tuska - I do not know what you mean, Folder names are hundreds of different, not one, in your image there is no expected result showing the folder name and EXTRACT to a different text file. Regex is wrong. What you showed is completely wrong !!!!
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

Debugger wrote:tuska - I do not know what you mean, Folder names are hundreds of different, not one, in your image there is no expected result showing the folder name and EXTRACT to a different text file. Regex is wrong. What you showed is completely wrong !!!!
I mainly referred to your statements:
Debugger wrote:This is too simple a regex that does not work in CSV files (cells). I use EmEditor.
I need a valid Regex, which is found path only in the second cell.
U:\AB.csv(17582306): "y_ddc1d451.jpg","Q:\AB Rysunki ALL!!\-32084290_146842073","117 KB","08-05-13 23:57:00"
search only green (2 cell)
Red - any combination of characters
It does not work! Regex is invalid.
Emeditor: Info: Cannot find ^"[^]*?","Q:\\AB
and just wanted to express that I do not receive this error message in EmEditor and that with me a text is found, if I
- split your search text "y_6faf5837.jpg","Q:\AB Rysunki ALL!!\-14533360_139830958","104 KB","09-05-13 01:59:55"
    e.g. in a file AB.csv -> "comma separated" (tab-separated and user-separated make no sense) in EmEditor
- enter the search parameters in the "Search" field (with the "Search" toolbar displayed)
- pressed the button "Use regular expressions"
- press the button "Find Next"

The following is found with the RegEx expression (marked in green - see picture above) in EmEditor:

Code: Select all

"y_ddc1d451.jpg","Q:\AB Rysunki ALL!!
https://www.regextester.com/
- Regular Expression: ^"[^"]*?","Q:\\AB Rysunki ALL!! --> /^"[^"]*?","Q:\\AB Rysunki ALL!!/g ... is shown
- Test string: "y_ddc1d451.jpg","Q:\AB Rysunki ALL!!\-32084290_146842073","117 KB","08-05-13 23:57:00"
finds "1 match" and "y_ddc1d451.jpg","Q:\AB Rysunki ALL!! is marked --> same as in EmEditor!

However, the "comma-separated" splitting in AB.csv is as follows:

Code: Select all

!-------------------!---------------------------------------------!
! Column A          ! Column B                                    !
!-------------------!---------------------------------------------!
! "y_ddc1d451.jpg", ! "Q:\AB Rysunki ALL!!\-32084290_146842073",  !
!-------------------!---------------------------------------------!
Because of the path in column B AND the extra data, it will probably be difficult
to extract the path from a .CSV file to a .TXT file without an additional column.
If I'm wrong, I'm sorry.

That's what it was about me on this subject, as I have no idea about RegEx (I tried this example just for the sake of interest).
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex to find all lines (paths)

Post by void »

Everything uses PCRE, I can't really help with Emeditor as I don't know what version of regex they are using. (Regex++?)

Searching for:
^"[^"]*","Q:\\AB Rysunki ALL!!

Might work, however ^"[^"]*" is greedy and may match more than one column.

If you want to capture the second column, please try searching for:
^"[^"]*","(Q:\\AB Rysunki ALL!![^"]*)"

Use \1 to recall the second column without quotes.
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

void wrote:Everything uses PCRE, I can't really help with Emeditor as I don't know what version of regex they are using. (Regex++?)
EmEditor F1 - Help, EmEditor How to: Regular Expression Syntax wrote:Regular Expression Syntax: EmEditor regular expression syntax is based on Perl regular expression syntax.
EmEditor Copyright Notice wrote: The regular expression routines used in EmEditor use Boost library Regex++ and Onigmo.
Copyright (C) Dr John Maddock
Copyright (C) K. Takata, based on Oniguruma Copyright (C) by K. Kosako.
EmEditor Help - About wrote:Regex++: Copyright (C) by Dr John Maddock (Boost 1.66.0)
Onigmo: Copyright (C) K. Takata, based on Oniguruma Copyright (C) by K. Kosako (Version 6.1.3)
In EmEditor the following can be selected in the menu "Tools" - "Customize ..." - "Search" by drop-down box:
- Default setting Regular Expression Engine: Boost.Regex --> Without change, this is set by default!
- Default setting Regular Expression Engine: Onigmo

For me, these examples continue to be unclear for me as why I'm in EmEditor search for a path with complicated RegEx-queries,
if I can enter part of the path in EmEditor in the field "Filter" (Filter Toolbar must be displayed; menu item/button for this exists in buttonbar):

Code: Select all

:\AB (insert one space after: :\AB )
While doing so only rows are displayed, which contain ":\AB " in the path and all other lines are hidden.

Apart from that, I wonder why Debugger did not continue to ask such questions in the other forum,
where he got so good information there.

----------
Btw, EmEditor v18.0.5 released!
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

EmEditor support Perl Regex

Here is a completely different regular expression that does not match any paths.

EmEditor:
Can not find ^"[^"]*","(Q:\\AB Rysunki ALL!![^"]*)" below the current position.
Besides the name "AB Drawings ALL !!" does not match many different folder names and subfolders.

This regular is completely different than anyone else's forum posting Total Commander(FORUM) and https://www.zabkat.com
My posts do not exist anymore because they have been deleted very long ago and no one even supports such requests.

It seems to me that the escape is invalid [E-Z]:\\ (not work) [E-Z]:/ (work)


Can not extract folder names or (folder names + subfolders)

Image
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

del
Last edited by Debugger on Tue Sep 04, 2018 4:46 pm, edited 1 time in total.
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

tuska, void - Your regex will not work because it is based on other examples. I clearly and clearly define what I really want to extract. Please, see previous posts again.

posting2.php?mode=quote&f=2&p=22896

Full name!!!:
U:\AB.csv(17582306): "y_ddc1d451.jpg","Q:\AB Rysunki ALL!!\-32084290_146842073","117 KB","08-05-13 23:57:00"

I want extract:
Q:\AB Rysunki ALL!!
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

2Debugger
As I mentioned above: "I have no idea about RegEx (I tried this example just for the sake of interest)".
Please keep that in mind.

Just out of interest I played around a little bit, with the following results:

Code: Select all

\\AB Rysunki ALL!! 	   finds   \AB Rysunki ALL!!	
[+Q?]:\\AB Rysunki ALL!! finds   Q:\AB Rysunki ALL!!    <------
.:\\AB Rysunki ALL!!	  finds   Q:\AB Rysunki ALL!!, Z:\AB Rysunki ALL!!
.:\\AB Rysunki ALL!!\\	finds	Q:\AB Rysunki ALL!!\	
.:\\AB 			         finds	X:\AB Z:\AB Q:\AB
.:\\AB (.*)\\		      finds   Q:\AB Rysunki ALL!!\ … and ... Z:\AB Karaiby & Plaża-\
I assume that you have this line somewhere in any file in EmEditor:
U:\AB.csv(17582306): "y_ddc1d451.jpg","Q:\AB Rysunki ALL!!\-32084290_146842073","117 KB","08-05-13 23:57:00"

If you search in EmEditor for: .:\\AB Rysunki ALL!!, pressed the button RegEx and the button "Find next" ...
at least I'll have Q:\AB Rysunki ALL!! marked here.

If there are several lines in EmEditor in which this path occurs, then this path is marked.

EDIT:
[+Q?]:\\AB Rysunki ALL!! should be used!
Last edited by tuska on Tue Sep 04, 2018 6:24 pm, edited 1 time in total.
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

2Debugger
[OT] EmEditor
Since I am also a beginner in EmEditor, I have a question for you now:
How do I have to proceed in EmEditor or what do I have to set to get such a context menu,
as you portrayed it above? The lines above of: ^ Beginning of Line are not shown to me.
It would be very kind of you to give me a tip.
[/OT]
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

Regular expression I did not need anymore REPLACE all escapes \ on , and set "Comma separated"(csv) and I chose one of the table, and now I have a ready list of 96 paths :)
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

Good for you.
Could you perhaps still answer my question?
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

My simple regex now returns the expected result

[Q-Z]:\\AK\s.+\\

Context menu? You mean it?

Image
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

2Debugger
[Q-Z]:\\AB\s.+\\
Now you have even been able to solve everything yourself!
---
Ahh, thanks!
I get the extended display via menu "Search" - "Search" … or Ctrl+F" - click on ">".
The "Find"-toolbar (>>) shows me only a part of it (so far that was enough for me).
Debugger
Posts: 630
Joined: Thu Jan 26, 2017 11:56 am

Re: Regex to find all lines (paths)

Post by Debugger »

The professional version has more options, fully functional for 30 days, later it changes automatically into free versions (limited).
EmEditor according to me the best and the fastest editor of large texts and many different operations, delete, replace.
Increasingly, the new version is faster (see list of changes) :D
Open a very large CSV file 5.39 seconds
* 1.99 GB, 156,600,000 lines, random number data, Use Temporary Files option on (default), Windows 10 (64-bit), Core i7-8700K, 32GB RAM.
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Regex to find all lines (paths)

Post by tuska »

Yes, I own EmEditor Professional.
Since you are working with CSV files, you should upgrade to version 18.0.7 because of a bug fix here.
Suggest, however, that we end the topic EmEditor here.

You could solve your request here yourself.
Post Reply