# Help with complex filter criteria

**URL:** https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798
**Category:** Mac
**Tags:** bug-fixed
**Created:** [July 2, 2022, 12:23am UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798 "2022-07-02T00:23:59Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![nojwe](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@nojwe](https://community.mp3tag.de/u/nojwe)
#### Post date: [July 2, 2022, 12:23am UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/1 "2022-07-02T00:23:59Z")

</div>

I'm trying to set a filter with the logic:

(title HAS Symphony)  
and  
(not title matches Symphony No. [0-9] in [A-G]( |-sharp |-flat )(Minor|Major),(| '(.\*?)',) (Op. |K|WoO )([1-9][0-9]{0,2}) - (I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV).)

Each works fine individually, but I get no results when combining them, even though I should. Any thoughts?

---

<div class="post-metadata">

### Author: ![poster](https://community.mp3tag.de/user_avatar/community.mp3tag.de/poster/32/4881_2.png) [@poster](https://community.mp3tag.de/u/poster)
#### Post date: [July 2, 2022, 4:15am UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/2 "2022-07-02T04:15:19Z")

</div>

Could you please post the exact filter expression for the combination.  
The one above cannot work, even individually, because "and" and "matches" and "not" have to be written in capitals.  
(I have not examined the regular expression)

---

<div class="post-metadata">

### Author: ![nojwe](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@nojwe](https://community.mp3tag.de/u/nojwe)
#### Post date: [July 2, 2022, 1:58pm UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/3 "2022-07-02T13:58:53Z")

</div>

Thank you. I did have AND capitalized in the filter, but not NOT. Changing that does give results, but still unexpected. For example a track simply titled "Aria" shows up, even though it doesn't meet the criteria set by the filter, specifically, title HAS Symphony.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [July 3, 2022, 3:48pm UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/4 "2022-07-03T15:48:49Z")

</div>

This should do the trick:

```nohighlight
(title HAS Symphony) AND NOT (title MATCHES "Symphony No\. [0-9] in [A-G]( |-sharp |-flat )(Minor|Major),(| '(.*?)',) (Op\. |K|WoO )([1-9][0-9]{0,2}) - (I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV)\.")

```

---

<div class="post-metadata">

### Author: ![nojwe](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@nojwe](https://community.mp3tag.de/u/nojwe)
#### Post date: [July 5, 2022, 2:00pm UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/5 "2022-07-05T14:00:42Z")

</div>

> [@Florian](#):
>
> `(title HAS Symphony) AND NOT (title MATCHES "Symphony No\. [0-9] in [A-G]( |-sharp |-flat )(Minor|Major),(| '(.*?)',) (Op\. |K|WoO )([1-9][0-9]{0,2}) - (I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV)\.")`

Unfortunately not. I get the same results. It appears to be an issue with NOT and AND together. Any filter I try that is something like: "(title HAS Symphony) AND NOT (artist HAS Berlin)" does not filter results at all. It's displaying 3997/3997 tracks. If I drop the NOT, it filters correctly. If I have a query with a single parameter, e.g. "NOT artist HAS Berlin", it filters correctly. "(title HAS Symphony) AND (artist HAS Berlin)" also filters correctly.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [July 6, 2022, 9:30am UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/6 "2022-07-06T09:30:37Z")

</div>

Thanks for your thorough analysis. In the meantime I've reviewed the code and wrote some additional tests which revealed a non-deterministic behavior in operator precedence 🤪

I'll work on a fix and will keep you posted.

---

<div class="post-metadata">

### Author: ![nojwe](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/n/f17d59/32.png) [@nojwe](https://community.mp3tag.de/u/nojwe)
#### Post date: [July 6, 2022, 2:21pm UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/7 "2022-07-06T14:21:29Z")

</div>

Thank you so much! Sorry about the bug, that sounds like it will be a bit of a pain to fix. I love this app though, definitely the best I've found for finally getting my library in order!

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [July 14, 2022, 7:18am UTC](https://community.mp3tag.de/t/help-with-complex-filter-criteria/57798/8 "2022-07-14T07:18:07Z")

</div>

I've just released Mp3tag for Mac v1.5.1 which fixes the non-deterministic behavior in filter operator precedence.

All your expressions should now work as expected — if you notice anything you can't explain, please let me know.
