Regex replace up to next bracket and move to artist

Hello everyone. I'm trying to set up some actions to delete the 'featuring' part from the title by using regex. I'm a total newbie at this and have gotten quite far by searching the forums for help but for now I can't get the following to work:

Current regex is
Field: TITLE
Regular Expression: \s+(fe?a?t.*)
Replace: (nothing)

When a variant of '(feat' is found this deletes everything up to the end of the tag when additional sets of round brackets are in the tag. I want it to end at the first round bracket after the match. So it should -not- remove any brackets before the match nor any following sets of brackets. For example:
title (feat. artist2) (radio edit)
currently becomes:
title
instead of:
title (radio edit)

What do I have to change in the regex to get this to work?
And additionally: how do I add the exact string that is matched by the regex to the artist field?

Many thanks in advance!
Wouter

see e.g. here:


or here:

1 Like

The second topic contained exactly what I needed to get rid of the 'featuring' from the title. Many thanks!

I'm reorganizing my actions now and will then try to make an action to add the found string to the Artist tag before deleting it.

These regex' are extremely powerful, but sometimes hard to 'read'.

I was the OP of the first topic that ohrenkino linked, and using what I know as well as the second post he linked, I think your best bet might be using the following two part action:

Field: ARTIST
Format string: $meta_sep(artist,\\)\\$regexp(%TITLE%,'^(.+?)\s+[[({]?(?:ft\.?|feat\.?|featuring)\s+([^][(){}]+)[])}]?(\s+.+)?$','$2',1)


Field: TITLE
Format string: $regexp(%TITLE%,'^(.+?)\s+[[({]?(?:ft\.?|feat\.?|featuring)\s+(?:[^][(){}]+)[])}]?(\s+.+)?$','$1$2',1)

1 Like

Sorry about multiple edits on my post, but now the format above should work properly.

Hello again,

@krmerman342: The action for the TITLE field matches my current one exactly.
Your proposal for the ARTIST field doesn't work the way it should however.
E.g. with

TITLE: songtitle (featuring feat_artist)
ARTIST: main_artist

the first action turn the ARTIST field into:

main_artist\\feat_artist

with two backslashes instead of:

main_artist featuring feat_artist

(On a side note: I also want to get rid of the brackets)

Ah, my apologies. I was attempting to mend a problem you aren't facing.
You would like a single artist field, not multiple. Instead, try this as the first part:

Field: ARTIST
Format string: %artist% featuring $regexp(%TITLE%,'^(.+?)\s+[[({]?(?:ft\.?|feat\.?|featuring)\s+([^][(){}]+)[])}]?(\s+.+)?$','$2',1)

1 Like

@kramerman342: Thank you so much, it's working perfectly now!
I'm still trying to 'decrypt' the regex formulae, it's fascinating what you can do with them.

Again thank you both very much for helping out!

Wouter

Something I'd like to suggest that you may have already tried:
https://regexr.com/
The website I linked may be inconsistent in some ways with what you input into MP3TAG, but it helped me a lot in making SOME sense out of what is happening "behind the scenes" of the regex. By hovering over your code you can read snippets of how the characters might interact with your tag in question. It will not show the exacts always, so beware and be sure to always test on one file before you use your regex on a collection of files!

@Zestje
This new website I'm linking is nearly identical in appearance to the last one I linked, but seems to do a better job at tracking the function of parenthesis/brackets as well as giving you that same visual representation of what's happening in your specific text (your tag), which I've already input so you can see it straight away!

1 Like

@kramerman342: Thank you very much, that website is amazing! Is really helped me understand the final bits of code.

Hey, I know that this post is solved, but this may just be a good spot for me to ask a question based on the regex that has already been used in this thread.
We know that using this:
Field: ARTIST
Format string: %artist% featuring $regexp(%TITLE%,'^(.+?)\s+[[({]?(?:ft\.?|feat\.?|featuring)\s+([^][(){}]+)[])}]?(\s+.+)?$','$2',1)
is useful in taking away the (feat._artist) part of the tag, but what if instead we wanted to copy over a Remix artist? I'm having a tough time rearranging to achieve that goal. I specifically want this style where all brackets (, [ & { are accounted for. Thanks to anybody who might be able to help.
@ohrenkino sorry to bother, but you always help me figure out what I might be missing! might you have any ideas?

P.S. I was able to create this:
$regexp(%title%,(.*)\s(?:[({[])(.*?[mM]ix|.*?[eE]dit|.*?[vV]ersion|.*?[aA]coustic)(?:[)}\]]),$1[$2]
https://regex101.com/r/0Z7XR9/7
Which appears to do EXACTLY what I need it to. Bringing it into MP3TAG doesn't quite work, though. There must be some slight tweak that I have to do to make it work!

I doubt that this expression would have worked at the other address as it is missing a closing parenthesis at the end.
You can test the regular expressions in MP3tag in the function Convert>Tag-Tag.

What are the characteristics of a Remix artist?
Regular expressions are all about patterns, they do not see any sematics. So you have to find the pattern and then use the regular expression to describe that pattern.
If the remix artist stands between the opening parenthesis and in front of the keyword Remix, then you have to cater for that by moving the part

to front and adapt the keywords.

I can't believe I didn't know this.

I also need to get better at rechecking before I post things. You're right about the closing parenthesis. When I used the function, there was an opening and closing parenthesis. I failed to copy the ending one. The website I linked just showed it as working (i know the program may differ) so I thought maybe I was close.
In the context of what I need this to work for, a remix artist is any artist in a grouping followed by the word "Remix."
As an example, in the following:
Title: SongName (Feat. Artist2) (RemixArtist Remix)

Let me be straightforward. I'm attempting to create a formatting tool that will discover any grouping ending in Mix/mix, Dub, Edit, Version, or Acoustic (or non-capitalized versions of each word), whether the grouping uses brackets, parenthesis, braces, or a mix-matched combination like ( } or [ ) that anything. I can then use another method to call out specifically my "Remix Artist."
I need a formatting tool that does this:
SongName (Feat. Artist2) (RemixArtist Remix) >>> SongName (Feat. Artist2) [RemixArtist Remix]
SongName (Feat. Artist2) [RemixArtist Edit} >>> SongName (Feat. Artist2) [RemixArtist Edit]
SongName (Feat. Artist2) {RemixArtist acoustic) >>> SongName (Feat. Artist2) [RemixArtist acoustic]
SongName (Feat. Artist2) {Extended version} >>> SongName (Feat. Artist2) [Extended version]
SongName (Feat. Artist2) [DubArtist Dub] >>> SongName (Feat. Artist2) [DubArtist Dub]

Perhaps this:
$regexp(%TITLE%,'^(.*?)\s+[\({](.*?)[\)}]\s+[\({](.*)[\)}]',$1 ($2) '['$3']')

If you want to use more unique separators, I would even suggest to use < > to separate the featured artist - as there are sometimes titles that have normal parenthesis just as an amendment like
Pink Floyd: Pigs (three different ones).
So the regexp could become:
$regexp(%TITLE%,'^(.*?)\s+[\({](.*?)[\)}]\s+[\({](.*)[\)}]',$1 <$2> '['$3']')

I can't seem to get this to work, but I'm going to look over it and see if I can't work something out.

I have found a solution that work for the current set-up, but I think I've made it far too convoluted and it also get confused if there's no feat. artist. If you'd like to take a look, this is the mess I've created:
$regexp(%TITLE%,'^(.*?)\s[[({]+(?:.+)?[[({]+(Mix|.+?Acoustic|.+?Edit|.+?Version|.+?Dub|.+?Remix)[])}]?$',$1' ['$2']')
see my results:


"Song1 Has Long Name (Feat. Artist2] (MixArtist Remix)" ->
"Song1 Has Long Name [MixArtist Remix]"

"Summer Days (feat. Macklemore & Patrick Stump of Fall Out Boy) (Junior Sanchez Remix)" ->
"Summer Days [Junior Sanchez Remix]"

"Track 3 Doesnt have Feature (Great Remix)" ->
"Track 3 Doesnt have Feature (Great Remix)"

*Note that the third did not change as hoped.
EDIT: It also completely deletes the featured artist, which I overlooked completely.

If the quote is that what you tried then it will not work as you are missing the bits inside the parenthesis.
I tested mine
$regexp(%TITLE%,'^(.*?)\s+[({](.*?)[])}]\s+[\({](.*)[\)}]',$1 <$2> '['$3']')
on
"Song1 Has Long Name (Feat. Artist2] (MixArtist Remix)"
and the result is:
"Song1 Has Long Name <Feat. Artist2> [MixArtist Remix]"
(I left out the square brackets as it looked to me that if they were there, everything was ok already but you can add any kind of these to the leading and trailing bits.
After you have classified the various pieces of data (title, featured artist, version) it should be easy to separate them to other fields.

1 Like

Nice! Upon trying it out on the same examples, it seemed to work on the first two, but suffered the curse of the third one in that it did not change it.

the third case is a different pattern: just a single pair of brackets.
So you need a different regexp.

1 Like

I see. I thought that perhaps I could make one that would serve both purposes. My mistake! Thank you, though. You've been helpful as always! :slight_smile: