Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Help with filter/regexp in Facets ! (Read 813 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Help with filter/regexp in Facets !

Hi,

I'm using the Facets plugin and struggling getting a filter working in Foobar and could use some help!  I basically want to filter the results where the start of the directory in the path is either "VA-" or "VA_-_" but with my limited knowledge of regular expressions its proving difficult!

This is what I have and I realise it doesn't test for "VA-" or "VA_-_", only "VA" but it's not working regardless.

 $if($left(%<directory>%,2)='VA'),%<album>%

Any help is much appreciated.

Cheers.

Re: Help with filter/regexp in Facets !

Reply #1
Not too sure about this but try it.

$if($or($strcmp($left(%directory%,2),VA),$strcmp($left(%directory%,5),VA_-_),%album%))

Re: Help with filter/regexp in Facets !

Reply #2
Thanks Jazzthief, I tried it but didn't work, it gives a syntax error.

I modified your expressions and found the following worked but doesn't obviously look for and find any of the "VA_-_" matches...

$if($strcmp($left(%directory%,3),VA-),%album%)



Re: Help with filter/regexp in Facets !

Reply #3
Read this:
http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Title_Formatting_Reference

Check if path contains 'VA-' (will evaluate true or false):
Code: [Select]
$strstr(%path%,VA-)

Check if path contains 'VA-' OR 'VA - ':
Code: [Select]
$or($strstr(%path%,VA-),$strstr(%path%,VA - ))

Wrap it inside an $if() function to decide what happens if it evaluates true or false:
Code: [Select]
$if($or($strstr(%path%,VA-),$strstr(%path%,VA - )),TRUE,FALSE)

Show %album% only if it the statement evaluated true:
Code: [Select]
$if($or($strstr(%path%,VA-),$strstr(%path%,VA - )),%album%,)

You may opt to substitute this for the first code in my post:
Code: [Select]
$strstr($directory(%path%,1),VA-)
It ensures that the matches are folders and also that they are exactly N level above the current track by swapping '%path%' with '$directory(%path%,1)'. Currently N is 1, which means the same folder as the file resides in. 2 would mean 2 levels above and so on. If you have variable directory structure this obviously won't work.

 

Re: Help with filter/regexp in Facets !

Reply #4
Hi Daeron,  thank your for the expressions this line works great ...
$if($or($strstr(%path%,VA-),$strstr(%path%,VA - )),%album%,)

$if($left(%directory%,3),%album%,)


One problem with it is that it evaluates the entire path for VA- and VA_-_  and it's showing results where the folder name starts with JVA, for example.  The reason I tried to use the $left operator was because I could rule out any false positives like this.  Could the expression above be  amended to search only the first 3 / 5 characters of the path or is this not possible.

Cheers
Paul