[X] Regular Expressions (Regex) - unintended repetition of strings


Not sure if this a bug or just me overlooking something, but my apologies in advance if it’s the latter. I’ve only started trying to use regular expressions in various programs about three months ago or so, and only a week or two ago in MP3Tag specifically, so I’m not by any means a Regex expert, or an MP3Tag scripting expert.

I’ve been using what seems to me like pretty straightforward and simple Regex code recently to append text and/or numbers to existing data in fields. For example, I’ve used the following sequence of actions and code to append to the COMMENT field:

Actions > Actions (Quick)
Replace with regular expressions

  Field: COMMENT
  Regular Expression: (.*)
  Replace matches with: \1 testing

If the COMMENT first contained “”, it now contains “ testing testing”. Why is my appended string being appended twice?

I’ve noticed in the Regular Expressions support/examples thread, here:


…that many others are using “$1” instead of “\1” to represent the matched string in the replacement expression. I was only familiar with “\1” from my Regex use in other programs (Notepad++, Directory Opus), but tried it both ways in MP3Tag, and got the same results either way.

Am I missing something?


Although I can also see this behaviour, the best way to append strings to an existing field contents would be an action of the type "Format value" and the
Format string %fieldname% append string


The problematic result looks like as if there are multiple regex matches in any way.

You can modify the input of the action "Replace with regular expression" this way:
Regular Expression: .+
replace matches with: $0 testing

... or apply Convert "Tag - Tag" ...
Formatstring: $regexp(%COMMENT%,'.+','$0 testing')



Both of your suggestions work — thank you, and thanks also to ohrenkino for suggesting I use Format Value — but I still don’t get why my original method results in two of the appended string. Multiple regex matches? Huh? I just tried my method again as follows:

5 MP3 files with comment “This is”
5 FLAC files with comment “There will be”

Replace with regular expression

Field: Comment
Regular expression: “(.*)”
Replace matches with: “$1 a test”

5 MP3 files with comment “This is a test a test”
5 FLAC files with comment “There will be a test a test”

How could multiple regex matches have come about from the above, and how would it explain the results?

But thanks again for the alternative suggestions.