Named groups and backreferences help
-
- Posts: 3
- Joined: Thu Oct 27, 2016 9:19 am
Named groups and backreferences help
Hi,
With 1.4.1 added perl compatible regex, how to use named groups syntax, any help?
Thanks.
With 1.4.1 added perl compatible regex, how to use named groups syntax, any help?
Thanks.
Re: Named groups and backreferences help
Capture and name a group:
(?P<name>...)
Invoke named group:
(?P=name)
For example: find files with the same name part and extension part:
regex:"^(?P<foo>.*)\.(?P=foo)$"
If you use regex: please make sure you escape <, >, | and spaces with double quotes.
https://en.wikipedia.org/wiki/Perl_Comp ... xpressions
(?P<name>...)
Invoke named group:
(?P=name)
For example: find files with the same name part and extension part:
regex:"^(?P<foo>.*)\.(?P=foo)$"
If you use regex: please make sure you escape <, >, | and spaces with double quotes.
https://en.wikipedia.org/wiki/Perl_Comp ... xpressions
-
- Posts: 3
- Joined: Thu Oct 27, 2016 9:19 am
Re: Named groups and backreferences help
Thanks.
Looks like i missed the double quotes, but not just for escape <, >, | and spaces, like also need double quotes
I did some tests with named groups and backreferences, to match '1212.txt', these syntax all works:
regex:"(12)\1.txt"
regex:"(?<x>12)\k<x>.txt"
regex:"(?'x'12)\k'x'.txt"
regex:"(?'x'12)\k{x}.txt"
regex:"(?'x'12)\g{x}.txt"
regex:"(?P<x>12)\k<x>.txt"
From: http://www.regular-expressions.info/refext.html
Looks like i missed the double quotes, but not just for escape <, >, | and spaces, like
Code: Select all
regex:"(12)\1.txt"
I did some tests with named groups and backreferences, to match '1212.txt', these syntax all works:
regex:"(12)\1.txt"
regex:"(?<x>12)\k<x>.txt"
regex:"(?'x'12)\k'x'.txt"
regex:"(?'x'12)\k{x}.txt"
regex:"(?'x'12)\g{x}.txt"
regex:"(?P<x>12)\k<x>.txt"
From: http://www.regular-expressions.info/refext.html
Re: Named groups and backreferences help
If you have Allow round bracket grouping enabled from Tools -> Options -> Search you will also need to escape ( and ) with double quotes.
-
- Posts: 3
- Joined: Thu Oct 27, 2016 9:19 am
Re: Named groups and backreferences help
Indeed.
Off the topic, does everything support condition search?
If find a.2.txt also list a.txt,
For example, find mutli groups similar files: a.txt, a.2.txt, c.txt, c.2.txt from list:
Off the topic, does everything support condition search?
If find a.2.txt also list a.txt,
For example, find mutli groups similar files: a.txt, a.2.txt, c.txt, c.2.txt from list:
Code: Select all
a.txt
a.1.txt
a.2.txt
b.txt
b.1.txt
c.txt
c.2.txt
Re: Named groups and backreferences help
No, not yet, sorry.
Re: Named groups and backreferences help
Hi,
is there the possibility to find existing filenames having the same name but different extensions (for example MyMovie.avi and MyMovie.mp4)?
Thanks
is there the possibility to find existing filenames having the same name but different extensions (for example MyMovie.avi and MyMovie.mp4)?
Thanks
Re: Named groups and backreferences help
namepartdupe:
Notes:
Requires Everything 1.4.1
namepartdupe: finds duplicated files and folders with the same name part in the entire index (not the current results).
For example:
namepartdupe:MyMovie
Notes:
Requires Everything 1.4.1
namepartdupe: finds duplicated files and folders with the same name part in the entire index (not the current results).
For example:
namepartdupe:MyMovie
Re: Named groups and backreferences help
Wow, thanks, I hadn't noticed it! Works great. Thanks.
Re: Named groups and backreferences help
Uhm... I was wrong... I forget to mention that I don't know the file name in advance
#part1
I just want to find what filenames have the same name but a different extension (last .xxx part)
Or at least I know two extensions (mp4 and avi) and I want to get as above.
#part2
Moreover, it seems I can not search for dupe filtering a specific volume only (filename that exists twice only int the same volume).
If i write
dupe: e:
it returns some dupes because the other files (the clones) are in the m: volume... that is a backup drive... and so I'm not interested in that...
Thanks
#part1
I just want to find what filenames have the same name but a different extension (last .xxx part)
Or at least I know two extensions (mp4 and avi) and I want to get as above.
#part2
Moreover, it seems I can not search for dupe filtering a specific volume only (filename that exists twice only int the same volume).
If i write
dupe: e:
it returns some dupes because the other files (the clones) are in the m: volume... that is a backup drive... and so I'm not interested in that...
Thanks
Re: Named groups and backreferences help
that's what namepartdupe: should do.#part1
I just want to find what filenames have the same name but a different extension (last .xxx part)
Or at least I know two extensions (mp4 and avi) and I want to get as above.
namepartdupe: will also find duplicated name parts with the same extension, ie the whole file name is duplicated.
namepartdupe: finds duplicated files and folders with the same name part in the entire index (not the current results).#part2
Moreover, it seems I can not search for dupe filtering a specific volume only (filename that exists twice only int the same volume).
If i write
dupe: e:
it returns some dupes because the other files (the clones) are in the m: volume... that is a backup drive... and so I'm not interested in that...
Please try running a new named instance of Everything and indexing only your m: drive.
Re: Named groups and backreferences help
Ok, ok, look at this (I want you know that I studied and put into practice some of your previous teachings)
Search for M: (to get an exhaustive list of all files in volume M:)
Export (to file list)
Open File List (to work only on items contained in M:)
namepartdupe:file:ext:mp4;avi (WOOW! FINALLY!)
Close File List (and go back to ordinary work)
Anyway, I'm very tired of your immediate availability: right today I will make another (small) donation!
Regards
Search for M: (to get an exhaustive list of all files in volume M:)
Export (to file list)
Open File List (to work only on items contained in M:)
namepartdupe:file:ext:mp4;avi (WOOW! FINALLY!)
Close File List (and go back to ordinary work)
Anyway, I'm very tired of your immediate availability: right today I will make another (small) donation!
Regards
Re: Named groups and backreferences help
Excellent, I didn't think of doing that.Search for M: (to get an exhaustive list of all files in volume M:)
Export (to file list)
Open File List (to work only on items contained in M:)
namepartdupe:file:ext:mp4;avi (WOOW! FINALLY!)
Thanks for your support.
Re: Named groups and backreferences help
Is there a way to invoke a named group (?P=name) to be used as the parameter for the content: function?
Re: Named groups and backreferences help
Not yet, sorry.
Added to my TODO list: regvar0:..regvar9: to be substituted with the previous regex search captures, possibly by name too.
Added to my TODO list: regvar0:..regvar9: to be substituted with the previous regex search captures, possibly by name too.
Re: Named groups and backreferences help
Thanks for TODOing...
These are (some) files I own
Aggiornamento Asset T3.xlsx
Aggiornamento Asset T4.xlsx
Aggiornamento Asset T5.xlsx
and this is a useful-to-me search example:
regex:"(?P<N1>Aggiornamento asset )(?P<N2>T[0-9]+)(?P<N3>.*)"
Based on your assumptions, a search for those containing the N2 result will be (?) like:
regex:"(?P<N1>Aggiornamento asset )(?P<N2>T[0-9]+)(?P<N3>.*)" AND content:regvar3:
These are (some) files I own
Aggiornamento Asset T3.xlsx
Aggiornamento Asset T4.xlsx
Aggiornamento Asset T5.xlsx
and this is a useful-to-me search example:
regex:"(?P<N1>Aggiornamento asset )(?P<N2>T[0-9]+)(?P<N3>.*)"
Based on your assumptions, a search for those containing the N2 result will be (?) like:
regex:"(?P<N1>Aggiornamento asset )(?P<N2>T[0-9]+)(?P<N3>.*)" AND content:regvar3: