TC704a: Lister, RegEx search back does not find all matches
Moderators: Hacker, petermad, Stefan2, white
TC704a: Lister, RegEx search back does not find all matches
* 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
* 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
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 11.03 / Win10 x64
Using TC 11.03 / Win10 x64
Ah, sorry, I read your post inattentively and thought you meant running TOTALCMD.exe, not viewing. In this case, yes, I confirm the bug.white wrote:Didn't you try TOTALCMD.exe?
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 11.03 / Win10 x64
Using TC 11.03 / Win10 x64
ts4242
In EmEditor it works fine, so it could be a problem of a particular implementation, not global.
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 11.03 / Win10 x64
Using TC 11.03 / Win10 x64
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.ts4242 wrote:EmEditor return 22 occurrence
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
Using TC 11.03 / Win10 x64
Using TC 11.03 / Win10 x64
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.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).
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.
- ghisler(Author)
- Site Admin
- Posts: 50475
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
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
https://www.ghisler.com
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.
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.