TC704a: Lister, RegEx search back does not find all matches

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

TC704a: Lister, RegEx search back does not find all matches

Post by *white »

* View TOTALCMD.exe (I tried version 7.04a packed and unpacked version) using the internal lister in normal, binary or hex view.
* Go to the end of the file
* Search backwards on "aaa" with RegEx enabled
* Repeat the search until no match is found and count the number of matches
* Compare the number of matches with the number of matches when you search forward from the top
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

Cannot reproduce. Maybe, it depends on the file contents.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Flint wrote:Cannot reproduce. Maybe, it depends on the file contents.
Didn't you try TOTALCMD.exe?
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

white wrote:Didn't you try TOTALCMD.exe?
Ah, sorry, I read your post inattentively and thought you meant running TOTALCMD.exe, not viewing. In this case, yes, I confirm the bug.

It can be even reproduced more easily, without necessity of counting occurences.
1. Open TOTALCMD.EXE for viewing in binary mode (I used UPXed version of TOTALCMD.EXE 7.04a).
2. Start searching aaa with regexp forward.
3. Scroll to the very end of the file.
4. Press F3 to search further -> no more aaa found.
5. Press Shift+F3 to search first occurence backward.
6. Press F3 to search forward again.
7. Though it should have been the last occurence (first from the end), TC finds another occurence of aaa (and even one more if you press F3 again).
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Flint wrote: It can be even reproduced more easily, without necessity of counting occurences.
Confirmed.
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

When I use EditPad Pro and check Regular Expression option in Search Panel, I see that, the Previous button automatically disabled.
I don't know the exact reason for disabling Previous button, but isn't that mean Regex backward search not allowed, otherwise the search result will not be accurate?
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

ts4242
In EmEditor it works fine, so it could be a problem of a particular implementation, not global.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

2Flint
EmEditor has wrong Regex implementation!
1. Create new text file and type string "aaaaaaaaaaaaaaaaaaaaaaaa" (24 a) and save it.
2. Open that file with EmEditor and Lister
3. Search for aaa using Regex
:arrow: Lister return 8 occurrence
:arrow: EmEditor return 22 occurrence
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ts4242 wrote:EmEditor has wrong Regex implementation!
Is it a wrong implementation or just a different implementation?
Using Lister and searching without RegEx also finds 22 matches..
User avatar
ts4242
Power Member
Power Member
Posts: 2081
Joined: 2004-02-02, 20:08 UTC
Contact:

Post by *ts4242 »

2white
All text editors I use return 8 matches when apply Regex, I think this is the correct result (or at least what I expecting when using Regex, otherwise what the difference between normal search and Regex search).
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

ts4242 wrote:EmEditor return 22 occurrence
Only when you perform search without using the string found. If you use e.g. Find/Replace (even if you replace it with the same "aaa"), it will find exactly 8 occurences.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ts4242 wrote:2white
All text editors I use return 8 matches when apply Regex, I think this is the correct result (or at least what I expecting when using Regex, otherwise what the difference between normal search and Regex search).
The difference between normal search and RegEx search is of course the syntax of the search pattern. Where to continue the search is a matter of design I would say. Personally, I would expect the search to continue at the same place when the same match is found using different search methods.

So when searching with normal search for "aaa" and searching with RegEx for "aaa", I would expect the search to continue at the same place.

Notepad++ for example finds 8 matches with normal, extended, or regular expression search.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Unfortunately using regex in non-text files is problematic because Regex search needs line breaks (it can search only within a line). Sorry, I don't have any solution for this problem.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Regular expressions were designed for data stream manipulation. With regular expressions one can do complex data stream manipulation using only a single line of code. Of course in a data stream the end of the stream is unknown, so backward searching is not supported.

Regular expressions do not need line breaks at all, but have sophisticated support for multi line searching.

Searching using regular expressions in Total Commander's Lister is implemented in a line by line matter. Perhaps this is done to implement a regular expression search that can search backwards.

It is probably best to remove the functionality to search backwards using regular expressions and enable the full power of multi line search and binary search capabilities of regular expressions.
Post Reply