# Extract pattern from filename to tag field (subtitle)

**URL:** <https://community.mp3tag.de/t/extract-pattern-from-filename-to-tag-field-subtitle/14603>\
**Category:** Support\
**Created:** [April 2, 2013, 12:05pm UTC](https://community.mp3tag.de/t/extract-pattern-from-filename-to-tag-field-subtitle/14603 "2013-04-02T12:05:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pqsc.user](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@pqsc.user](https://community.mp3tag.de/u/pqsc.user)\
**Post date:** [April 2, 2013, 12:05pm UTC](https://community.mp3tag.de/t/extract-pattern-from-filename-to-tag-field-subtitle/14603/1 "2013-04-02T12:05:25Z")

</div>

> [@Re-formatting the ARTIST field based on info from ALBUM](https://community.mp3tag.de/t/re-formatting-the-artist-field-based-on-info-from-album/14602/1):
>
> Worked! Nice one, thanks very much 😃

I have a similar question / problem.  
I'm sure it's quite easy but new to regular expressions.  
I'd like to extract from %\_filename% certain patterns (a code) and assign them to %subtitle%

Examples:

1985-07-14 S-1972  
1991-12-22 - PN-42  
Shortwave VF-759

In the above example, I'd like to extract the S-1972, PN-42, and VF-759.

The numbers will change -AND- can either be at the beginning, middle, or end of the %\_filename%. In all cases, the pattern will either be S-, PN-, or VF-.

Tried and tried but can't seem to get my $regexp to work.

Help! Please....

---

<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, 2013, 1:04pm UTC](https://community.mp3tag.de/t/extract-pattern-from-filename-to-tag-field-subtitle/14603/2 "2013-04-02T13:04:06Z")

</div>

> [@pqsc.user](#):
>
> I have a similar question / problem.

No.

> [@](#):
>
> a: 1985-07-14 S-1972  
> b: 1991-12-22 - PN-42  
> c: Shortwave VF-759

You have to look for the underlying pattern.  
So in this case a: and c: are the same as they have a single word in front, followed by blank and then a third part which should be extracted. The keyword here is the similar separator  
Thy could be treated by a gues values action and the value string %dummy% %subtitle%  
Example b: has " - " as separator. so it has be treated differently  
%dummy% - %subtitle%

Alternatively, you could first smply copy all data into to field subtitle and then strip the leading information with a "Replace with regular expression" action.  
use this search string:  
^.\* (\w+-\d+)  
Replace string:  
$1

---

<div class="post-metadata">

**Author:** ![pqsc.user](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@pqsc.user](https://community.mp3tag.de/u/pqsc.user)\
**Post date:** [April 2, 2013, 6:47pm UTC](https://community.mp3tag.de/t/extract-pattern-from-filename-to-tag-field-subtitle/14603/3 "2013-04-02T18:47:32Z")

</div>

> [@ohrenkino](#):
>
> Alternatively, you could first smply copy all data into to field subtitle and then strip the leading information with a "Replace with regular expression" action.  
> use this search string:  
> ^.\* (\w+-\d+)  
> Replace string:  
> $1

Thank you so much for replying!

AND, the reg. expr. you provided worked!!

The only glitch was when the Code had a non-white space after the last digit.

I think I need some sort of OR.

How would I place it after the "\d+" ?  
Something like this? \d+(\s|\S)

Again, thank you for replying....

---

<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, 2013, 3:56am UTC](https://community.mp3tag.de/t/extract-pattern-from-filename-to-tag-field-subtitle/14603/4 "2013-04-03T03:56:10Z")

</div>

> [@pqsc.user](#):
>
> ...  
> The only glitch was when the Code had a non-white space after the last digit.

I would use the $trim() function in an action of the type "Format value".

---

<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:24pm UTC](https://community.mp3tag.de/t/extract-pattern-from-filename-to-tag-field-subtitle/14603/5 "2026-02-09T12:24:25Z")

</div>

Closed on February 9, 2026, 12:24pm UTC


