# In Regular Expression (\\w\*|\\W\*) works but (.\*) doesn't

**URL:** https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611
**Category:** Support
**Created:** [February 19, 2011, 7:09pm UTC](https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611 "2011-02-19T19:09:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bacoms](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@bacoms](https://community.mp3tag.de/u/bacoms)
#### Post date: [February 19, 2011, 7:09pm UTC](https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611/1 "2011-02-19T19:09:45Z")

</div>

Hi all, I've searched the FAQs for the solution to this but to no avail so hopefully someone can throw some light on why the obvious solution doesn't work in MP3Tag.

All I'm trying to do is add the composer, found at the beginning of the filename before the first dash (-), to the Composer field. For example; extract the composer 'Albinoni' from the filename:

> Albinoni-Trumpet Concerto in C (IV - Allegro)

My first attempt was to define a 'Format value' action into which I coded the following Format string:

> $regexp(%\_FILENAME%,^(.\*)-?(.\*),$1 )

This simply created the whole filename as the composer.

After many hours of research (I'm no expert on regular expressions) and lots of trial and error, in desperation I tried the following Format string:

> $regexp(%\_FILENAME%,^(\w\*|\W\*)-?(.\*),$1 )

and bugger me it worked, producing the result Albinoni as required.

Surely "\w\*|\W\*" is just an obtuse way of writing ".\*" or have I misunderstood something?????

---

<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 19, 2011, 7:19pm UTC](https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611/2 "2011-02-19T19:19:21Z")

</div>

> [@bacoms](#):
>
> ... add the composer, found at the beginning of the filename before the first dash (-)

Why don't you use the converter filename - tag with a mask  
%composer%-%dummy%  
or, if you insist on an action a format field action that looks like this:  
$left(%\_filename%,$strstr('-'))

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [February 19, 2011, 7:38pm UTC](https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611/3 "2011-02-19T19:38:04Z")

</div>

> [@bacoms](#):
>
> Hi all, I've searched the FAQs for the solution to this but to no avail so hopefully someone can throw some light on why the obvious solution doesn't work in MP3Tag. All I'm trying to do is add the composer, found at the beginning of the filename before the first dash (-), to the Composer field. For example; extract the composer 'Albinoni' from the filename:
> 
> > Albinoni-Trumpet Concerto in C (IV - Allegro)
> 
> ...

Hi bacoms, I am sure, that you can find the information in the FAQ area to solve your problem.  
And reading the forum posts can help too.

To solve your problem there are several ways to go.

- use the converter "Filename - Tag"
- use an action "Guess values"
- use the some more sophisticated action and function which deal with regular expressions, if you know how it works. You cannot grab a regular expression from elsewhere and hope it would work anyway. You have to understand what you do.

So give this a try ...  
Action "Guess values"  
Source Format: %\_FILENAME%  
Formatstring: **%COMPOSER%-%DUMMY%**

... or this ...  
Converter Filename - Tag:  
Formatstring: **%COMPOSER%-%DUMMY%**

... or this ...  
Action "Format value":  
Field: COMPOSER  
Formatstring: **$regexp(%\_filename%,'^(.+?)-(.+?)$','$1')**

... or this ...  
Action "Format value":  
Field: COMPOSER  
Formatstring: **$regexp(%\_FILENAME%,^(._?)-(._)$,$1)**  
(nearly the same expression as your attempt, but without the writing errors)

Good luck!

Practical usages of the "Guess Values" action can be found in the forum ...  
[http://www.google.de/search?q=site%3Aforum...+guess%2Bvalues](http://www.google.de/search?q=site%3Aforums.mp3tag.de+guess%2Bvalues)

DD.20110219.2155.CET

---

<div class="post-metadata">

### Author: ![bacoms](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@bacoms](https://community.mp3tag.de/u/bacoms)
#### Post date: [February 22, 2011, 12:05pm UTC](https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611/4 "2011-02-22T12:05:30Z")

</div>

Thanks for replying. With your help I now have a better understanding of the intricacies of MP3Tag which I only use very occasionally.

> [@ohrenkino](#):
>
> Why don't you use the converter filename - tag with a mask  
> %composer%-%dummy%  
> or, if you insist on an action a format field action that looks like this:  
> $left(%\_filename%,$strstr('-'))

P.S.1. For anyone also looking for a solution, the actual format field action that worked in my example is:  
$left(%\_filename%,$sub($strstr(%\_filename%,'-'),1))  
P.S.2. Similarly, to remove the composer (and the dash) from the filename, I used the following format action field:  
$right(%\_filename%,$sub($len(%\_filename%),$strstr(%\_filename%,'-')))

---

<div class="post-metadata">

### Author: ![bacoms](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/b/a6a055/32.png) [@bacoms](https://community.mp3tag.de/u/bacoms)
#### Post date: [February 22, 2011, 12:08pm UTC](https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611/5 "2011-02-22T12:08:50Z")

</div>

Thanks for all the alternative solutions. They have helped me gain a much better understanding of the intricacies of MP3 Tag.

---

<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:22pm UTC](https://community.mp3tag.de/t/in-regular-expression-w-w-works-but-doesnt/11611/6 "2026-02-09T12:22:55Z")

</div>


