# Help to Regular expression :)

**URL:** <https://community.mp3tag.de/t/help-to-regular-expression/45037>\
**Category:** Support\
**Created:** [April 2, 2019, 5:32pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037 "2019-04-02T17:32:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rmortensen84](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@Rmortensen84](https://community.mp3tag.de/u/Rmortensen84)\
**Post date:** [April 2, 2019, 5:32pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/1 "2019-04-02T17:32:05Z")

</div>

Hello I want help removing the date in the year field (Regular expression):

2010\2010-03-01 --------\>2010

Someone who can help ??

---

<div class="post-metadata">

**Author:** ![zappaphone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zappaphone/32/6308_2.png) [@zappaphone](https://community.mp3tag.de/u/zappaphone)\
**Post date:** [April 2, 2019, 6:01pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/2 "2019-04-02T18:01:22Z")

</div>

How about  
^[0-9]{4}\K.\*

Here we match the first four digits with ^[0-9]{4}  
Then we use \K to keep the text matched so far out of the overall regex match.  
And lastly we use .\* to match the rest of the string witch is the part that will be removed.

You would use Actions \> Actions (Quick) \> Replace with regular expression

**Field** : YEAR  
**Regular expression** : ^[0-9]{4}\K.\*  
**Replace matches with** stays empty.

---

<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:** [April 2, 2019, 8:02pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/3 "2019-04-02T20:02:33Z")

</div>

> [@Rmortensen84](#):
>
> year field
> 
> 2010\2010-03-01 --------\>2010

If the regular expression is not mandatory, I am a real fan of the action "Guess value" (import tag fields)  
Source: %year%  
Target: `%year%\%dummy%`

---

<div class="post-metadata">

**Author:** ![zappaphone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zappaphone/32/6308_2.png) [@zappaphone](https://community.mp3tag.de/u/zappaphone)\
**Post date:** [April 2, 2019, 8:17pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/4 "2019-04-02T20:17:57Z")

</div>

> [@ohrenkino](#):
>
> If the regular expression is not mandatory, I am a real fan of the action "Guess value" (import tag fields)

Yes, that will work too, but **Guessing pattern** must then be adjusted depending on what is in the **Year** field. For example, if the **Year** field contains **2010-03-01** , then the **Guessing pattern** must be **%year%-%dummy%** , and if the field contains **2010.03.01** it must be **%year%.%dummy%**. If the field actually contains **2010\2010-03-01** , then **%year%\%dummy%** would work.

---

<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:** [April 3, 2019, 6:28am UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/5 "2019-04-03T06:28:40Z")

</div>

> [@zappaphone](#):
>
> but **Guessing pattern** must then be adjusted

You are right.  
What about an action of the type "Format value" for YEAR  
Format string: $num(%year%,1)  
This should always take that what stands in front of the first non-numeric character.

---

<div class="post-metadata">

**Author:** ![zappaphone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zappaphone/32/6308_2.png) [@zappaphone](https://community.mp3tag.de/u/zappaphone)\
**Post date:** [April 3, 2019, 1:08pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/6 "2019-04-03T13:08:15Z")

</div>

> [@ohrenkino](#):
>
> What about an action of the type "Format value" for YEAR

True, that is a good one.

---

<div class="post-metadata">

**Author:** ![Rmortensen84](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/9f8e36/32.png) [@Rmortensen84](https://community.mp3tag.de/u/Rmortensen84)\
**Post date:** [April 3, 2019, 3:14pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/7 "2019-04-03T15:14:08Z")

</div>

> [@ohrenkino](#):
>
> This should always take that what stands in front of the first non-numeric character.

Thanks for the answer can you explain to me how this command works?

---

<div class="post-metadata">

**Author:** ![zappaphone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zappaphone/32/6308_2.png) [@zappaphone](https://community.mp3tag.de/u/zappaphone)\
**Post date:** [April 3, 2019, 3:24pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/8 "2019-04-03T15:24:07Z")

</div>

> [@Rmortensen84](#):
>
> Thanks for the answer can you explain to me how this command works?

To use this command, you select **Actions** \> **Actions (Quick)** \> Choose **Format value** \> **OK**

**Field** : YEAR  
**Format string** : $num(%year%,4)

The **$num** fuction returns the year number with 4 digits, padding with leading zero(s), in this case if the number is below 4 digits.

Another function that could be used is left:  
$left(%year%,4)

This is a string function and returns the leftmost characters of a string, in this case first 4 characters.

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [February 9, 2026, 12:28pm UTC](https://community.mp3tag.de/t/help-to-regular-expression/45037/9 "2026-02-09T12:28:00Z")

</div>


