photools.com Community

IMatch Bug Reports and Feature Requests => Bug Reports => Solved Bug Reports (for next version) => Topic started by: axel.hennig on September 09, 2022, 02:23:00 PM

Title: Category Formulas and Variables -> regular expression not working correct
Post by: axel.hennig on September 09, 2022, 02:23:00 PM
I tried to replicate this example from the help-page (see screenshot): https://www.photools.com/help/imatch/cat_formulas.htm (https://www.photools.com/help/imatch/cat_formulas.htm)
sc1.jpg

To be concrete, this example:
@Category[@All|Beach|Daytona]
Therefore I've created a category-tree like the following:
@All
|- Beach
  |- Daytona
|- Beach Club
  |- Hawaii
|- Mountains
  |- Daytona
|- Places
  |- Beach
      |- Daytona

I've added to the categories:
"@All|Beach|Daytona":        pic_1
"@All|Beach Club|Hawaii":    pic_2
"@All|Mountains|Daytona":    pic_3
"@All|Places|Beach|Daytona": pic_4

But when I enter in a new category the formula
@Category[@All|Beach|Daytona]it just returns pic_1. But the help says it should also return pic_2 ("@All|Beach Club|Hawaii"). And from my understanding it should also return pic_3 ("@All|Mountains|Daytona"). But it doesn't.

VarToy-app
The VarToy-app gives - at least to my understanding - a different result. When entering
{File.Categories|filter:@All|Beach|Daytona}it returns:

pic_1: Beach|Daytona        -> correct
pic_2: Beach Club|Hawaii    -> correct
pic_3: Mountains|Daytona    -> correct
pic_4: Places|Beach|Daytona  -> wrong (should be just empty / no result)
Title: Re: Category Formulas and Variables -> regular expression not working correct
Post by: thrinn on September 09, 2022, 04:37:08 PM
Thinking about your question, I am not sure anymore if the example in the help ist correct. From my understanding, @Category[@All|Beach|Daytona] should look for categories which contain "Beach" in their first level and, at the same time, "Daytona" in the second level. Thus, this expression should find "@All|Beach|Daytona" as well as "@All|Beach Club|Daytona Beach Club", but not "@All|Beach Club|Hawaii", because the second level does not match.

Regarding Vartoy: The filter expression is just a RegExp, so you will get all categories containing "Beach" or "Daytona" anywhere in the full category path. This is not directly comparable to the special handling in the @Category formula.
Title: Re: Category Formulas and Variables -> regular expression not working correct
Post by: axel.hennig on September 09, 2022, 04:58:22 PM
Hi Thorsten,
thanks for looking into this topic.

I think the question is if @Category[@All|Beach|Daytona] is:

The help (https://www.photools.com/help/imatch/cat_formulas.htm) says: When you expression begins with @All, IMatch considers every level specified individually. To me that sounds like an OR not an AND.


Regarding your VarToy reply: I think it should be exactly the same behaviour, not differently. Why: The help (https://www.photools.com/help/imatch/var_basics.htm) says: The filter function allows you to filter the categories of a file by a regular expression, identical to the @Category[] category formula
Title: Re: Category Formulas and Variables -> regular expression not working correct
Post by: thrinn on September 09, 2022, 08:07:46 PM
Quote from: axel.hennig on September 09, 2022, 04:58:22 PMRegarding your VarToy reply: I think it should be exactly the same behaviour, not differently. Why: The help (https://www.photools.com/help/imatch/var_basics.htm) says: The filter function allows you to filter the categories of a file by a regular expression, identical to the @Category[] category formula
I understand what you are saying. But @Category[] has two different syntax variants, so to say: One where the argument starts with @All, another one where the argument does not start with @All. Vartoy behaves more like the second variant described here. (https://www.photools.com/help/imatch/cat_formulas.htm?dl=h-17)
Title: Re: Category Formulas and Variables -> regular expression not working correct
Post by: Mario on September 12, 2022, 10:27:19 AM
I think the Hawaii example is wrong. I wrote that several years ago, so this is an old glitch.
I also think that IMatch works correctly.

You run a regexp on the following pattern:

@All|Beach|Daytona

which means that IMatch processes each level individually. So it first matches :

Beach

on all your top-level categories. Which finds two matches:

Beach|Daytona
Beach Club|Hawaii

Now it matches Daytona (next level down) against

Daytona
Hawaii

and the only match is Daytona of course. It would work when your categories are named:

Beach|Daytona
Beach Club|Daytona

or when your expression is something like:

"@Category[@All|Beach|.*]"

I shall update the help to fix this.
Title: Re: Category Formulas and Variables -> regular expression not working correct
Post by: axel.hennig on September 13, 2022, 01:36:08 PM
@Thorsten and Mario: Thanks for clarification.