Question regarding search (ALT+F7 "Find Files")...

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

Regexp... Как много в этом слове... <beware! strong salivation here>

I agree with JackFoo that there must be a parameter for memory buffer (if I understood correct, like sliding buffer in Lister). Just in case... Who knows what may become necessary in the future... Some extraordinary task...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

And other - will you implement regexp searches in the same thread - or other?
Curently the search function isn't multi-threaded, sorry. Can you give me an example of a regular expression which hangs?
Author of Total Commander
https://www.ghisler.com
User avatar
ado
Senior Member
Senior Member
Posts: 445
Joined: 2003-02-18, 13:22 UTC
Location: Slovakia, Pezinok

Post by *ado »

Would a per line search (limited to, say, 1k lines) be sufficient?
Christian, Please, 10k at least. A found a lot of XML config. files without "NewLine"....

...and personaly I would prefer if you can extend line size in internal Listener to ~10k too

ado
oblomov
Junior Member
Junior Member
Posts: 98
Joined: 2003-04-04, 15:41 UTC

Post by *oblomov »

ghisler(Author) wrote:
What library are you using (or have you created your own.. icon_eek.gif ) ?
I'm using this one:

http://anso.virtualave.net/

The advantage is that it's free also for commercial use, so no problem to add to my software. I also had no problems to build it with Delphi 2.0, and it seems to be fast too.
Is there a particular reason why you didn't use Perl Compatible Regular Expressions (www.pcre.org)?
ghisler(Author) wrote:Btw, what do you think, should regular expressions be case sensitive or insensitive by default? I plan to make it configurable, but what should be the default? I ask because file names are case-insensitive on Windows, but regular expressions come from Unix and are therefore usually case-sensitive...
I would say case insensitive by default
ghisler(Author) wrote:Currently my problem is how to support regex for text searches. A user could define an expression which matches a whole 2 GB file - too large to hold in memory. Any ideas? Would a per line search (limited to, say, 1k lines) be sufficient? And how to handle binary files?
Maybe a buffered search instead of something line-based? A (configurable in the .ini) "window" that scrolls on the file, preventing regexes from being too hungry? OTOH, badly-written regexes are supposed to misbehave ... if the user doesn't know what he's doing, he shouldn't be using regexes in the first place :) If he does and the computer goes to sleep for overstress .... maybe just provide a "cancel" (or "skip file") button?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Is there a particular reason why you didn't use Perl Compatible Regular Expressions (www.pcre.org)?
Yes, several!
- PCRE is written in C/C++, so I would have to use it in an external DLL, not compiled into the EXE
- PCRE is huge, so I could no longer deliver TC on a single floppy
- the library which I'm using now already supports a large set of regular expressions. Have you tried the precompiled sample?
Author of Total Commander
https://www.ghisler.com
oblomov
Junior Member
Junior Member
Posts: 98
Joined: 2003-04-04, 15:41 UTC

Post by *oblomov »

ghisler(Author) wrote:the library which I'm using now already supports a large set of regular expressions. Have you tried the precompiled sample?
Uh, no. Which precompiled sample? :)
User avatar
soreno
Junior Member
Junior Member
Posts: 87
Joined: 2003-02-13, 13:04 UTC
Location: Denmark

Post by *soreno »

User avatar
gromit
Junior Member
Junior Member
Posts: 25
Joined: 2003-06-25, 03:01 UTC
Location: Perth Western Australia
Contact:

Post by *gromit »

ghisler(Author) wrote:
Btw, what do you think, should regular expressions be case sensitive or insensitive by default? I plan to make it configurable, but what should be the default? I ask because file names are case-insensitive on Windows, but regular expressions come from Unix and are therefore usually case-sensitive...
I feel it should be case sensitive, so as not to detract from the power regEx offers.
Phil
User avatar
Valentino
Power Member
Power Member
Posts: 706
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

2gromit
Christian means (if I understood correctly) "by default". So this is configurable. No power detraction.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, it's configurable. And I will probably make it case insensitive by default.
Author of Total Commander
https://www.ghisler.com
User avatar
gromit
Junior Member
Junior Member
Posts: 25
Joined: 2003-06-25, 03:01 UTC
Location: Perth Western Australia
Contact:

Post by *gromit »

ghisler(Author) wrote:Yes, it's configurable. And I will probably make it case insensitive by default.
That'll be great 8)

I've seen what can be achieved using RegExp in my Newsreader (Forté Agent) and it would be an excellent addition to TC.

:D
Phil
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

An update about regular expressions support: I have now added regular expression searches both to the search function and to Lister.

As a compromise, regular expressions are applied to the searched file line by line, so they cannot reach over multiple lines. Also there is a maximum line length of 4k. These are the same limitations as in the pcregrep tool (a sample program comming with the PCRE library recommended by oblomov above).

Btw, I checked PCRE, and it doesn't have any special support for files either, so I will continue to use my current library. It only increases the totalcmd.exe size by 8k when packed with UPX or ASPack!
Author of Total Commander
https://www.ghisler.com
User avatar
sergeycentral
Junior Member
Junior Member
Posts: 34
Joined: 2003-07-24, 02:48 UTC
Location: USA

Post by *sergeycentral »

First of all, thanks for the regular expression searching option!! I have long been awating this also. :D

I have a question about how it will be presented. For instance, when selecting a group of files, could you have a button ("RegExp" :idea: ) next to "Define" lets say, that would show the different expressions available, eliminating the stress of memorizing them?....or using:

:arrow: Funduc's Search and Replace Regular Expression Wizard

Sergey
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Currently on select/unselect files, you have to begin a regular expression with the character < (this is similar to defined searches, where you use <). In the "Find files" dialog, both < and a checkbox labeled "RegEx" work.
Author of Total Commander
https://www.ghisler.com
oblomov
Junior Member
Junior Member
Posts: 98
Joined: 2003-04-04, 15:41 UTC

Post by *oblomov »

ghisler(Author) wrote:An update about regular expressions support: I have now added regular expression searches both to the search function and to Lister.
Cool :)
ghisler(Author) wrote:As a compromise, regular expressions are applied to the searched file line by line, so they cannot reach over multiple lines. Also there is a maximum line length of 4k.
I don't know if 4K will suffice (but I guess that if it won't, it'll get expanded in the next next version :)). About searching line-by-line: a (complex) way to handle the thing could be to see if the regexp needs a multi-line search (has things like \r or \n or something like that) and only enable multi-line in that case. Not sure about it should work, though.
Post Reply