# Filtering out differently styled track numbers in filename

**URL:** <https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077>\
**Category:** Support\
**Created:** [February 15, 2023, 3:13pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077 "2023-02-15T15:13:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 15, 2023, 3:13pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/1 "2023-02-15T15:13:26Z")

</div>

Hello Everyone,

**A.]** The objective is to set up a filter, which is applicable to file names. The filter should find the file names in which the track number matches the following numbering style:

101  
206.  
710.  
911.

— Three numerals _followed by a dot_, all of which are located _at the very beginning_ of the file name.

**B.]** Can one filter be made to cover in one application the matches for differently styled track numbers, all located at the beginning of the file name? Here follows an example of the track numbers in question:

10  
74.  
101.  
706.  
1-15.  
6-15.

The method eludes me, completely, hence, I welcome your assistance — if only for the aforementioned, much needed **A.]**

%\_filename% HAS ?

Thank you.

PS. The first number, as shown in each of the two series above, deliberately does not have the obligatory dot to avoid the message text getting re-formatted.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 15, 2023, 3:18pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/2 "2023-02-15T15:18:10Z")

</div>

> [@ragtag](#):
>
> Three numerals _followed by a dot_

try:  
`%_filename% MATCHES "^\d\d\d\."`

the `\d` stands for a **d** igit - and 3 of them for 3 digits.  
So, to filter for

> [@ragtag](#):
>
> 1-15

Try:  
`%_filename% MATCHES "^\d-\d\d\."`  
or  
`%_filename% MATCHES "^\d+-\d+\."`

and you can join them:  
`%_filename% MATCHES "^\d\d\d\." OR %_filename% MATCHES "^\d+-\d+\."`

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [February 15, 2023, 3:27pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/3 "2023-02-15T15:27:00Z")

</div>

For those asking what the `^\d+-` means:

![image](https://community.mp3tag.de/uploads/default/original/2X/b/bb930b9a50ecec834feb5c162f720f371d53a19b.png)

A **d** igit ("number") that exists at least once or unlimited times, followed by a `-` in the first occurence and followed by a `.` ("dot") for the second occurence.  
_The dot is a special character in regular expressions and has to be escaped with a_ `\.`

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 15, 2023, 3:35pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/4 "2023-02-15T15:35:35Z")

</div>

Thank you very much to you both, @ohrenkino and @LyricsLover. Especially also, to both of you for adding the explanations in there, too. I am beginning to recognise some of the patterns now.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 15, 2023, 4:38pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/5 "2023-02-15T16:38:10Z")

</div>

2 posts were split to a new topic: [Insert text with a regular expression in the filename](https://community.mp3tag.de/t/insert-text-with-a-regular-expression-in-the-filename/60079)

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 15, 2023, 5:47pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/6 "2023-02-15T17:47:12Z")

</div>

A post was merged into an existing topic: [Insert text with a regular expression in the filename](https://community.mp3tag.de/t/insert-text-with-a-regular-expression-in-the-filename/60079/3)

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 16, 2023, 1:59pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/7 "2023-02-16T13:59:50Z")

</div>

I would like to revisit this topic with a question (or two):

> %\_filename% MATCHES "^\d\d\d."`
> 
> the `\d` stands for a **d** igit - and 3 of them for 3 digits.

1. Since the "^\d\d\d." indicates 3 digits, what does the filter-syntax for "any number" of digits look like? Something like this, maybe?:

\d\*\

1. What is to gain by using the parenthesis around the Field name in filters, since it appears to be not a necessity? Perhaps prudence?

2. Are the parenthesis around the filter-syntax required for an exact search of the term?

Thank you.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 16, 2023, 2:04pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/8 "2023-02-16T14:04:42Z")

</div>

> [@ragtag](#):
>
> parenthesis around the filter-syntax

> [@ragtag](#):
>
> `\d\*

would be "any number, including no number at all".  
If there should be at least 1 digit:  
`\d+`

AFAIK there is no special purpose for parenthesis in the filter regular expressions.  
I wonder where you found that.

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 16, 2023, 2:37pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/9 "2023-02-16T14:37:15Z")

</div>

> would be "any number, including no number at all".  
> If there should be at least 1 digit:  
> `\d+`

Thank you very much, @ohrenkino

> AFAIK there is no special purpose for parenthesis in the filter regular expressions.  
> I wonder where you found that.

My question concerning the parenthesis arose from utilising Boolean search parameters, which, I thought, perhaps might have some relevance here.

Could you please confirm whether parenthesis are to be used whenever an regular expression operator, such as one of the following, are deployed:

"$" or "^" or ""

For instance example, in the album field, I want to find anywhere in the description, the words:

(CD(followed by any number)^

After reading your reply, is this the correct way to construct the filter for it?:

%album% HAS (CD\d+\^

or,

should the caret be enclosed in parentheses, thus —

%album% HAS (CD\d+\"^"

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [February 16, 2023, 2:49pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/10 "2023-02-16T14:49:10Z")

</div>

The `^` and `$` sign are also special characters in regular expressions.

The `^` means at position "Start of line"  
The `$` means at position "End of line"

"Line" in our case is the content of a tag or a filename for example.

Please have a look at the documentation:

> **[Regular Expressions – Mp3tag Documentation](https://docs.mp3tag.de/regex/#line-anchors)**
>
> Documentation on support for regular expressions in Mp3tag. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [February 16, 2023, 2:52pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/11 "2023-02-16T14:52:58Z")

</div>

> [@ragtag](#):
>
> Could you please confirm whether parenthesis are to be used whenever an regular expression operator, such as one of the following, are deployed:

No, the parenthesis are there to "collect/remember" the matched digits or characters.  
For example, if you want to replace the matched characters with some other values, you need the parenthesis. They build groups for later use.

@ohrenkino gave you a solution for filenames, using such parenthesis:

> [@Insert text with a regular expression in the filename](https://community.mp3tag.de/t/insert-text-with-a-regular-expression-in-the-filename/60079/2):
>
> If you want to keep the number, then you have to tell MP3tag that it should remember it - which is done by enclosing the pattern in parenthesis. So for something like 101. My music file which should become 1-01. My music file Try: Search pattern: ^(\d)(.\*) Replace string: $1-$2 Further information about regular expressions can be found in the documentation:

If you want so search for parenthesis as ordinary character, you have to escape them like this `\(` for an opening bracket and `\)` for a closing bracket

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [February 16, 2023, 3:03pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/12 "2023-02-16T15:03:06Z")

</div>

> [@ragtag](#):
>
> For instance example, in the album field, I want to find anywhere in the description, the words:
> 
> (CD(followed by any number)^

If you really want to search for  
opening bracket `(`  
`CD`  
opening bracket `(`  
`any number, including no number at all`  
closing bracket `)`

it would be something like  
`%album% MATCHES "\(CD\(\d*\)"`

If you only search for  
`CD`  
`followed by any number, including no number at all`  
it would be  
`%album% MATCHES CD\d*`

_In most cases you should also check, if there is a space before and after CD and brackets too._

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 16, 2023, 3:30pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/13 "2023-02-16T15:30:38Z")

</div>

Thank you, @LyricsLover

I have much to work with. My problem stems from using the caret "^", the regex special character, as part of the album name for multi-disc albums, for example:

Album name A (CD3^6)  
Album name B (CD07^16)

Therefore, the caret is part of the field description, _and_ part of the expression. How these play on each other, is what I am trying to understand.

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [February 16, 2023, 3:57pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/14 "2023-02-16T15:57:00Z")

</div>

> [@ragtag](#):
>
> Therefore, the caret is part of the field description, _and_ part of the expression

Ahh, I see.

If you search for a text or number which has to be mandatory at the start position or at the end position, you have to use the `^` as very first character in your regular expression and/or `$` as very last character in your regular expression.

if you search for `^` as part of your album name, as in your example  
`Album name A (CD3^6)`  
then you have to escape the `^` as special character with `\^` like this:  
`%album% MATCHES \^`  
(this would search for any occurence of ^ in your current %album% tag).  
Or more specifically:  
`%album% MATCHES CD\d+\^\d+`  
(search for `CD` followed by at least one digit, followed by ^, followed by at least one digit.)  
And explicitly for your given content:  
`%album% MATCHES "\(CD\d+\^\d+\)"`  
(search for an opening bracket, followed by `CD` followed by at least one digit, followed by ^, followed by at least one digit, followed by a closing bracket.)

If you define that the above regular expression should only match, if this combination is the last part in your tag (= nothing is allowed to follow after the closing bracket), then you could add the $ function like this:  
`%album% MATCHES "\(CD\d+\^\d+\)$"`

Here is a list of such special characters with "[double meaning](https://docs.mp3tag.de/regex/#literals)". They all need to be escaped to search for them literally.  
_(Sorry, I don't know the exact english word for this double functionality.)_

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 16, 2023, 5:09pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/15 "2023-02-16T17:09:54Z")

</div>

Thank you for explaining it well, and for the examples you have provided along with it. I will learn how to apply them.

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 17, 2023, 12:32pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/16 "2023-02-17T12:32:38Z")

</div>

> (search for CD followed by at least one digit, followed by ^, followed by at least one digit.)  
> And explicitly for your given content:  
> %album% MATCHES "(CD\d+^\d+)"  
> (search for an opening bracket, followed by CD followed by at least one digit, followed by ^, followed by at least one digit, followed by a closing bracket.)

Having tried the aforesaid filter courtesy of @LyricLover, and not seeing the desired results, I tried out more of my own combinations for hours on end, to try and learn something from the experience. Of course, none did the job, because, eventually, I noticed an error I made in my original presentation here: _I omitted a space between the word "CD" and the first digit following after it, which in turn is directly followed by the caret "^"_.

(  
CD  
_Space_  
1st single, or, multi-digit  
^  
2nd single, or, multi-digit  
)

_Examples:_

(CD\_1^6)  
(CD\_10^12)

_where: the underscore "\_" represents the space._

I gave up here: `%album% MATCHES \(CD\s\d+\^\d+\)`. Please, show me where I erred?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 17, 2023, 12:36pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/17 "2023-02-17T12:36:18Z")

</div>

> [@ragtag](#):
>
> `%album% MATCHES \(CD\s\d+\^\d+\)`

`%album% MATCHES "\(CD\s\d+\^\d+\)"`

Have a look at the notes about filter strings:

> **[Filter and Search – Mp3tag Documentation](https://docs.mp3tag.de/filter/#notes)**
>
> Documentation on Filter and Search and keywords to form complex filter expressions. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 17, 2023, 1:29pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/18 "2023-02-17T13:29:43Z")

</div>

Parenthesis! Thank you, @ohrenkino. _Always_ use parenthesis to enclosing the regular expressions?

(Also, do any "Literals" have to be put in parentheses whenever it is used in a regular expression?).

---

<div class="post-metadata">

**Author:** ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)\
**Post date:** [February 17, 2023, 1:30pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/19 "2023-02-17T13:30:42Z")

</div>

Not parenthesis `()`, double quotation marks `""`

 ![image](https://community.mp3tag.de/uploads/default/original/2X/e/e083e3574fe6c6ed89967a7ddd7da836e16dff9b.png)

---

<div class="post-metadata">

**Author:** ![ragtag](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ragtag/32/13146_2.png) [@ragtag](https://community.mp3tag.de/u/ragtag)\
**Post date:** [February 17, 2023, 1:49pm UTC](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077/20 "2023-02-17T13:49:56Z")

</div>

It feels like the person quickly downing an alphabet soup, expecting to speak the language fluently afterwards. 🤕

Thank you, both.

[Next page](https://community.mp3tag.de/t/filtering-out-differently-styled-track-numbers-in-filename/60077.md?page=2)
