Formulas

Discussion related to "Everything" 1.5.
Post Reply
don_don
Posts: 6
Joined: Fri Feb 16, 2024 7:38 pm

Formulas

Post by don_don »

Question: Is it possible to display content from the file something like:
voidtools search: some*.XML add_column:a a=:REGEX_EXTRACT($content,"ABCD:.*$")
and have the results show to end of line (or to end of word with different regex)

result:
ABCD: 23 or ABCD:my dog Spot ??
What is the syntax?

Thanks for any help
Last edited by don_don on Wed Mar 05, 2025 6:12 pm, edited 1 time in total.
NotNull
Posts: 5961
Joined: Wed May 24, 2017 9:22 pm

Re: Formulas

Post by NotNull »

don_don wrote: Wed Mar 05, 2025 3:03 pm some*.XML add_column:a a=:REGEX_EXTRACT($content,"ABCD:.*$")
You were very close!

Code: Select all

some*.XML  add_column:a  a:=:REGEX_EXTRACT($content:,"ABCD:.*")
Changes:
-- := instead of =:
-- ":" at the end of $content:
-- "ABCD:.*" instead of "ABCD:.*$"
"ABCD:.*$" will search for ABCD, but only on the the last line of the file.
Without it i will try to match ABCD on any line in the file.


Another way to get this result:

Code: Select all

some*.XML  regex:content:(ABCD.*) add-column:regular-expression-match-1
or

Code: Select all

some*.XML  regex:fromdisk:content:(ABCD.*)  addcol:1
don_don
Posts: 6
Joined: Fri Feb 16, 2024 7:38 pm

Re: Formulas

Post by don_don »

Great! Thank you.

What is the fromdisk: function in your example? Why is it only there sometimes? I cant find any explanation in this inside the program (v1.5.0.1391) or in the formula section.
NotNull
Posts: 5961
Joined: Wed May 24, 2017 9:22 pm

Re: Formulas

Post by NotNull »

Typical Everything syntax is search-modifier-1:search-modifier-2:search-function:"some value"
The order of the search-modifiers is arbitrary; Everything is clever enough to figure it out.

fromdisk: is a search modifier.
It changes the way content is searched as it bypasses the indexed content in Everything's database by reading the content from the file on disk.


And as I don't know if you indexed this specific content or not (configured under Menu => Tools => Options => Indexes => Content), I added fromdisk: to the search to be on the safe side.
Might be slower if that content was indeed indexed, but works in all cases.

fromdisk: is not needed if that content was already indexed.

For the full picture (and to confuse you even more ;)):
if no content is indexed at all, fromdisk: can be left out too, as Everything will understand that it has to get this information from disk.



fromdisk:.
don_don
Posts: 6
Joined: Fri Feb 16, 2024 7:38 pm

Re: Formulas

Post by don_don »

Thanks for clarifying how fromdisk: works

This is an occasional search so happy for it to search content and not have it indexed.

One more minor problem: my processing with regex extract() and mid() return a number in quotes
e.g. "0.9", "9.5914", "0.12", "15.154"
i want to sort these in numerical order but to do that i need to remove the quotes
i don't seem to be able to use substitute to find a double quote character

Code: Select all

SUBSTITUTE(text,?,"")  where  the ? is any of these experiments:
- triple quotes """
- &quot:
- "&quot:"
-  escaping double quote inside double quotes "\""
i tried regex_replace with the same search terms and none of these work.
NotNull
Posts: 5961
Joined: Wed May 24, 2017 9:22 pm

Re: Formulas

Post by NotNull »

Not sure if I understood correctly, but instead of post-processing the outcome, it should be possible to filter out all unwanted characters using a different REGEX_EXTRACT().

Something like the following:

Code: Select all

some*.XML   add_column:A    A:=REGEX_EXTRACT($content:,"ABCD: ""(.+?)""")
This will search for ABCD: " and extract everything after that until the first "
don_don
Posts: 6
Joined: Fri Feb 16, 2024 7:38 pm

Re: Formulas

Post by don_don »

Thanks! That puts me on the right track and is much easier than post-processing:
sample text from file:

Code: Select all

ABCD="9.51"
and using search to find text between the first and second double quotes

Code: Select all

 add_column:a  a-label:=ABCD  a:=REGEX_EXTRACT($content:,"ABCD=""(.+?)""")


(I can't see this in the forum but only in my notifications. Is that because of the url switching for the spam? Or is there something else?)
Post Reply