Page 2 of 2
Re: Find Files, Contents, Grep feature
Posted: 26 Oct 2011 12:28
by Stefan
admin wrote:If your pattern is a*b then it would match "ab", "axb", "axxb", "axxxb" etc.
because wildcard * means "any number of characters".
In XY's content search, however, this "any number" is restricted.
The whole matching string "axxx.....b" will surely be found only if it is no longer than 1024 chars.
It *might* be found if it is no longer than 32,768 chars. I will not be found if it longer than 32,768 chars.
Question to be more clear:
1.) i imagine it like this:
Code: Select all
Searching [b]a*b[/b] on
"First chunk of 1024 chars [b]axxx..."
"...b[/b] Second chunk of 1024 chars"
will fail then OR It *might* be found.
Right?
2.)
Second question: what means *might* in this case for you? What are the conditions?
Re: Find Files, Contents, Grep feature
Posted: 26 Oct 2011 13:01
by admin
I read in chunks of 32,768 chars, and have them overlap by 1,024 chars.
Re: Find Files, Contents, Grep feature
Posted: 26 Oct 2011 16:13
by Stefan
admin wrote: If your pattern is a*b then it would match "ab", "axb", "axxb", "axxxb" etc. because wildcard * means "any number of characters".
In XY's content search, however, this "any number" is restricted.
The whole matching string "axxx.....b" will surely be found only if it is no longer than 1024 chars.
It *might* be found if it is no longer than 32,768 chars.
I will not be found if it longer than 32,768 chars.
admin wrote:I read in chunks of 32,768 chars, and have them overlap by 1,024 chars.
Understood. Thanks.
Code: Select all
|------------------------------------ file size -----------------------------------------|
xxxxxxxxx 32,768 chars xxxxxxxxxxxx chunk 1
|1,024 chars| overlap
xxxxxxxxxxxxx 32,768 chars xxxxxxxxxxxxx chunk 2
|1,024 chars| overlap
xxxxxxxxxxxxx 32,768 chars xxxxxxxxxxxxx chunk ...
The RegEx search pattern (find string)
"should be" less then 1024 chars to be able to match inside an chunk and even in the overlap between two chunks,
but "could be" up to 32768 chars but with no chance to match this, if the string to match is spread over two chunks
Re: Find Files, Contents, Grep feature
Posted: 26 Oct 2011 20:48
by admin
Bingo!

Re: Find Files, Contents, Grep feature
Posted: 31 Oct 2011 05:27
by Ash
Don,
Thanks for the example and clarification, I understand now.
Most of my Regexp searches are in sourcecode files and are quite localised to smaller parts (eg. a single line) of the file so the 1024 wildcard limit should not be noticed.
It's good to have this discussion here so you can refer other users to this if they have similar questions.
Ash
Re: Find Files, Contents, Grep feature
Posted: 24 Aug 2018 14:13
by dhrv
When finding content in files, is it possible to display a column that shows the matched part and the context around it, similar to "grep -B5 -A5 mystring dir/"? There are standalone tools for Windows that can do this (grepWin, dnGrep) but it would be helpful to have this feature in XYplorer.
Re: Find Files, Contents, Grep feature
Posted: 24 Aug 2018 14:34
by highend
I don't think that this makes much sense (at least when it comes to linebreaks) but you could try to write a custom column script for this.
E.g.:
gets you the content of the "Contents" field from the last search
Have fun building the necessary regexes for the cc script, though...
Re: Find Files, Contents, Grep feature
Posted: 24 Aug 2018 14:44
by admin
dhrv wrote:When finding content in files, is it possible to display a column that shows the matched part and the context around it, similar to "grep -B5 -A5 mystring dir/"? There are standalone tools for Windows that can do this (grepWin, dnGrep) but it would be helpful to have this feature in XYplorer.
It would be a useful thing. I'll think about it.
Re: Find Files, Contents, Grep feature
Posted: 24 Aug 2018 15:10
by dhrv
Thanks for the quick replies. Hehe yeah, you're right, I even struggle to extract the first match properly (btw, is it possible to apply basic formatting like bold or italics to parts of the text of the custom column?). If I'm successful, I will post the script here, if not, I let Donald surprise me

Re: Find Files, Contents, Grep feature
Posted: 24 Aug 2018 16:46
by highend
How do you want to display multiple /r/n or /n separated lines of "surrounding text lines" in a single line column so that it makes sense for the user?
Apart from that, regexmatching isn't hard but you shouldn't forget that this could produce many lines depending on how often the search text is found...
Code: Select all
$stringToFind = "word";
$string = <<<>>>
1st line
2nd line
3rd line
4th line
a word to find
6th line
7th line
8th line
9th line
>>>;
// Incl. two lines before
text "Before: <crlf>" . regexmatches($string, "(^.*\r?\n){2}.*?" . $stringToFind, <crlf>);
// Incl. three lines after
text "After: <crlf>" . regexmatches($string, $stringToFind . "(.*\r?\n){4}", <crlf>);
btw, is it possible to apply basic formatting like bold or italics to parts of the text of the custom column?
Nope, not atm...