Page 1 of 1
Regular Expressions in the Contents of Find Files
Posted: 17 Oct 2008 07:25
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.
Re: Regular Expressions in the Contents of Find Files
Posted: 17 Oct 2008 07:39
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
Re: Regular Expressions in the Contents of Find Files
Posted: 17 Oct 2008 08:27
by Dan Phillips
j_c_hallgren wrote:Hi and wlcome to the XY forums!
Thanks jch.
No, that's a different thing.
Re: Regular Expressions in the Contents of Find Files
Posted: 17 Oct 2008 09:16
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.

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...

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.
Re: Regular Expressions in the Contents of Find Files
Posted: 20 Oct 2008 12:26
by Dan Phillips
admin wrote:straightforward to implement...
depends.

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.

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!
Re: Regular Expressions in the Contents of Find Files
Posted: 20 Oct 2008 12:40
by admin
Dan Phillips wrote:admin wrote:straightforward to implement...
depends.

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.

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.
Re: Regular Expressions in the Contents of Find Files
Posted: 20 Oct 2008 12:46
by admin
admin wrote:Dan Phillips wrote:admin wrote:straightforward to implement...
depends.

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.

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!

Re: Regular Expressions in the Contents of Find Files
Posted: 21 Oct 2008 13:51
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.
Re: Regular Expressions in the Contents of Find Files
Posted: 21 Oct 2008 14:22
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"...

Re: Regular Expressions in the Contents of Find Files
Posted: 30 Nov 2008 19:08
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
Re: Regular Expressions in the Contents of Find Files
Posted: 01 Dec 2008 08:36
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.
Re: Regular Expressions in the Contents of Find Files
Posted: 02 Dec 2008 21:55
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!
Re: Regular Expressions in the Contents of Find Files
Posted: 03 Dec 2008 08:25
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?