# Regular expressions only work once

**URL:** <https://community.mp3tag.de/t/regular-expressions-only-work-once/58949>\
**Category:** Support\
**Created:** [November 2, 2022, 8:03pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949 "2022-11-02T20:03:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smugdruggler](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@Smugdruggler](https://community.mp3tag.de/u/Smugdruggler)\
**Post date:** [November 2, 2022, 8:03pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/1 "2022-11-02T20:03:28Z")

</div>

Hi,

I am trying to use the following regular expressions to remove the first 5 characters of all track titles that I have for an album.

1. `^.*?\d\s`  
& 2) `$cutleft(%title%,5)`

To test I selected track 1 and applied my action which worked exactly as expected. So I thought I could now do the remaining 20 tracks with confidence that my regular expression was correct, I then selected all of the remaining tracks and again applied the action however nothing happened, worse my expression has ceased to work at all!  
I thought maybe you cannot apply a regular expression to multiple selections so this time selected only one track but no it again did not work.

I then closed MP3TAG and reopened and again selected one track and applied the action but it still does not work.

I have tried other regular expressions that work as described above and they work as expected but as soon as I select multiple tracks and apply the expressions they too stop working.

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

Why is this?

---

<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:** [November 2, 2022, 8:09pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/2 "2022-11-02T20:09:55Z")

</div>

> [@Smugdruggler](#):
>
> Why is this?

This is very hard to say as you neither show us the original data nor the regular expression.  
Also, you don't say what "does not work" mean for you.

---

<div class="post-metadata">

**Author:** ![Smugdruggler](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@Smugdruggler](https://community.mp3tag.de/u/Smugdruggler)\
**Post date:** [November 2, 2022, 8:28pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/3 "2022-11-02T20:28:37Z")

</div>

Hi ohrenkino,

My apologies I clean forgot to paste that detail before I created the topic.

I have edited my post above.

---

<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:** [November 2, 2022, 8:33pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/4 "2022-11-02T20:33:14Z")

</div>

Try  
Action of the type "Format value" for TITLE  
Format string: `$regexp(%title%,^\d+ - ,)`  
You can test that expression in Convert\>Tag-Tag

---

<div class="post-metadata">

**Author:** ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)\
**Post date:** [November 2, 2022, 9:36pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/5 "2022-11-02T21:36:24Z")

</div>

> [@Smugdruggler](#):
>
> I have tried other regular expressions that work as described above and they work as expected but as soon as I select multiple tracks and apply the expressions they too stop working.

The number of files selected does not affect the execution of regular expressions or scripting functions.  
You might have misinterpreted what is happening.  
Also, `$cutleft(%title%,5)` is a [scripting function](https://docs.mp3tag.de/scripting/), not a regular expression.  
It is all you need to remove the first 5 characters of all track titles.  
A regex could be used for your specific title structure (as shown above), but is not necessary.

---

<div class="post-metadata">

**Author:** ![Smugdruggler](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@Smugdruggler](https://community.mp3tag.de/u/Smugdruggler)\
**Post date:** [November 2, 2022, 11:20pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/6 "2022-11-02T23:20:29Z")

</div>

> [@ohrenkino](#):
>
> `$regexp(%title%,^\d+ - ,)`

Hi ryerman, thanks for the response, you are right I had not understood that I was trying to use a scripting function as a regular expression. Strange though that it worked just the once. However the regular expression that I did use "^.\*?\d\s " also only worked just the once.

I have now used the string function "$cutleft(%title%,5)" on multiple selections successfully by inserting it into Convert\>Tag-Tag.

Many thanks

---

<div class="post-metadata">

**Author:** ![Smugdruggler](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@Smugdruggler](https://community.mp3tag.de/u/Smugdruggler)\
**Post date:** [November 2, 2022, 11:23pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/7 "2022-11-02T23:23:45Z")

</div>

Hi ohrenkino,

I tried "$regexp(%title%,^\d+ - ,)" as you suggested and it worked on multiple selections.

Many thanks for your help.

---

<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:** [December 2, 2022, 11:24pm UTC](https://community.mp3tag.de/t/regular-expressions-only-work-once/58949/8 "2022-12-02T23:24:34Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
