Regular Expressions in the Contents of Find Files

Features wanted...
Post Reply
Dan Phillips
Posts: 5
Joined: 17 Oct 2008 07:16

Regular Expressions in the Contents of Find Files

Post by Dan Phillips »

It would be good if the user could specify a regular expression in the Contents tab of Find Files. I would find such a feature very useful, and (I imagine!) it would be straightforward to implement.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Regular Expressions in the Contents of Find Files

Post by j_c_hallgren »

Hi and wlcome to the XY forums!

Is this the same as this recent wish? http://www.xyplorer.com/xyfc/viewtopic.php?f=5&t=3030
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Dan Phillips
Posts: 5
Joined: 17 Oct 2008 07:16

Re: Regular Expressions in the Contents of Find Files

Post by Dan Phillips »

j_c_hallgren wrote:Hi and wlcome to the XY forums!
Thanks jch.
Is this the same as this recent wish? http://www.xyplorer.com/xyfc/viewtopic.php?f=5&t=3030
No, that's a different thing.

admin
Site Admin
Posts: 66307
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regular Expressions in the Contents of Find Files

Post by admin »

Dan Phillips wrote:It would be good if the user could specify a regular expression in the Contents tab of Find Files. I would find such a feature very useful, and (I imagine!) it would be straightforward to implement.
straightforward to implement... depends. :wink: For small files, sure. But content search is, of course, built to deal with files of any length. I don't know what the RegExp engine (which I have not written myself but am using) will do when I feed it 2GBs of data...

:idea: PS: If one would deliberately limit the size of the found match to say 1000 bytes then RegExp -- and also simple wildcards!! -- would be possible. E.g. if I search for "a*b" then a match would be only found where "a" and "b" are within a string of 1000 bytes.

Dan Phillips
Posts: 5
Joined: 17 Oct 2008 07:16

Re: Regular Expressions in the Contents of Find Files

Post by Dan Phillips »

admin wrote:straightforward to implement... depends. :wink: For small files, sure. But content search is, of course, built to deal with files of any length. I don't know what the RegExp engine (which I have not written myself but am using) will do when I feed it 2GBs of data...
Good point. You would have to load the entire file into a string---i.e into memory---in order to feed it into the RegExp engine, which as you say could be problematic.
:idea: PS: If one would deliberately limit the size of the found match to say 1000 bytes then RegExp -- and also simple wildcards!! -- would be possible. E.g. if I search for "a*b" then a match would be only found where "a" and "b" are within a string of 1000 bytes.
Do you mean walking through the file line by line? That is how grep works. I think would be fine. What happens when a line is over the 1000 bytes though? You would give up on that line, but would you communicate that fact to the user? If so, that would present a user interface challenge; if not, then it would be a silent failure (bad).

I take back my claim that it would be straightforward to implement!

admin
Site Admin
Posts: 66307
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regular Expressions in the Contents of Find Files

Post by admin »

Dan Phillips wrote:
admin wrote:straightforward to implement... depends. :wink: For small files, sure. But content search is, of course, built to deal with files of any length. I don't know what the RegExp engine (which I have not written myself but am using) will do when I feed it 2GBs of data...
Good point. You would have to load the entire file into a string---i.e into memory---in order to feed it into the RegExp engine, which as you say could be problematic.
:idea: PS: If one would deliberately limit the size of the found match to say 1000 bytes then RegExp -- and also simple wildcards!! -- would be possible. E.g. if I search for "a*b" then a match would be only found where "a" and "b" are within a string of 1000 bytes.
Do you mean walking through the file line by line? That is how grep works. I think would be fine. What happens when a line is over the 1000 bytes though? You would give up on that line, but would you communicate that fact to the user? If so, that would present a user interface challenge; if not, then it would be a silent failure (bad).

I take back my claim that it would be straightforward to implement!
Well I just uploaded the feature and explained now I did it and what are the rules. I don't read linewise but chunkwise, and the chunks overlap by 1024 bytes if a wildcard pattern is stated.

admin
Site Admin
Posts: 66307
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regular Expressions in the Contents of Find Files

Post by admin »

admin wrote:
Dan Phillips wrote:
admin wrote:straightforward to implement... depends. :wink: For small files, sure. But content search is, of course, built to deal with files of any length. I don't know what the RegExp engine (which I have not written myself but am using) will do when I feed it 2GBs of data...
Good point. You would have to load the entire file into a string---i.e into memory---in order to feed it into the RegExp engine, which as you say could be problematic.
:idea: PS: If one would deliberately limit the size of the found match to say 1000 bytes then RegExp -- and also simple wildcards!! -- would be possible. E.g. if I search for "a*b" then a match would be only found where "a" and "b" are within a string of 1000 bytes.
Do you mean walking through the file line by line? That is how grep works. I think would be fine. What happens when a line is over the 1000 bytes though? You would give up on that line, but would you communicate that fact to the user? If so, that would present a user interface challenge; if not, then it would be a silent failure (bad).

I take back my claim that it would be straightforward to implement!
Well I just uploaded the feature and explained now I did it and what are the rules. I don't read linewise but chunkwise, and the chunks overlap by 1024 bytes if a wildcard pattern is stated.
Sorry, confusion, I did not yet do RegExp! :oops:

Dan Phillips
Posts: 5
Joined: 17 Oct 2008 07:16

Re: Regular Expressions in the Contents of Find Files

Post by Dan Phillips »

admin wrote:Well I just uploaded the feature and explained now I did it and what are the rules. I don't read linewise but chunkwise, and the chunks overlap by 1024 bytes if a wildcard pattern is stated.
That's clever how you've done it. (I assume you search a chunk of 32768 bytes, and then jump forward 32768 - 1024 = 31744 bytes, and then search again.)
It also *might* be found if "a" and "b" are within a range of 1,001 to 32,768 bytes!
Is 1001 correct? I think it should be 1025.

admin
Site Admin
Posts: 66307
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regular Expressions in the Contents of Find Files

Post by admin »

Dan Phillips wrote:
admin wrote:Well I just uploaded the feature and explained now I did it and what are the rules. I don't read linewise but chunkwise, and the chunks overlap by 1024 bytes if a wildcard pattern is stated.
That's clever how you've done it. (I assume you search a chunk of 32768 bytes, and then jump forward 32768 - 1024 = 31744 bytes, and then search again.)
It also *might* be found if "a" and "b" are within a range of 1,001 to 32,768 bytes!
Is 1001 correct? I think it should be 1025.
Yep, you assume alright.

Oh, yes, 1025. I first overlapped 1000 chars, but then decided to "think binary"... :)

lhsisson
Posts: 2
Joined: 30 Nov 2008 18:14

Re: Regular Expressions in the Contents of Find Files

Post by lhsisson »

I recently purchased XYPlorer and am just getting started with it. I'm a programmer and I'm very interested in incorporating regexp content searching if that is possible. Has anyone found a way to do this? A couple of editors I use (Notepad++, UltraEdit) implement that capability.

Thanks, Len

admin
Site Admin
Posts: 66307
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regular Expressions in the Contents of Find Files

Post by admin »

lhsisson wrote:I recently purchased XYPlorer and am just getting started with it. I'm a programmer and I'm very interested in incorporating regexp content searching if that is possible. Has anyone found a way to do this? A couple of editors I use (Notepad++, UltraEdit) implement that capability.

Thanks, Len
Hi Len, welcome!

The easiest way would be if I added that feature. So I take this as a wish.

lhsisson
Posts: 2
Joined: 30 Nov 2008 18:14

Re: Regular Expressions in the Contents of Find Files

Post by lhsisson »

Yes, do please take this as a wish.
In the meantime, is it possible through the scripting to launch a grep program such as Astrogrep for the directory currently selected? Astrogrep can be attached as a context menu item to Explorer. That would be a great capability to add to XYplorer in general (not just for Astrogrep) It is open-source so the source is available (VS 2003 .NET 1.1) http://astrogrep.sourceforge.net/

Unfortunately, it is against company policy to install such software on the company notebook I'm using for most my software development at the present time. That is why I purchased XYplorer, since it can run portable. Again, I'm a newbie to XYplorer so I'll be exploring such capabilities while waiting for the wish to come true.

Thanks for a great product!

admin
Site Admin
Posts: 66307
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regular Expressions in the Contents of Find Files

Post by admin »

lhsisson wrote:Yes, do please take this as a wish.
In the meantime, is it possible through the scripting to launch a grep program such as Astrogrep for the directory currently selected? Astrogrep can be attached as a context menu item to Explorer. That would be a great capability to add to XYplorer in general (not just for Astrogrep) It is open-source so the source is available (VS 2003 .NET 1.1) http://astrogrep.sourceforge.net/
That can easily be done through scripting or through a UDC. What's the command line syntax for Astrogrep to open a directory?

Post Reply