Regex to Extract Artists After First

Looking for a Regex guru to help me with this one please
I am making use of a custom tag ‘Guest Artist’ and want any artists that appear as a second, third, fourth etc. value in Artists to be copied into this tag. I do not want the first (main) artist when there is only one value in Artists

Example

Artists: Artist1; Artist2; Artist3
Guest Artist: Artist2; Artist3

I tried
$setmulti(Guest Artist,$rreplace(%artists%,^[^;]*;,))
Which works on multi-artist tracks as planned but returns Artist1 for tracks which only have a single artist

Anyone care to help please?

Have a look at the plugin that I mentioned in:

I believe that it will quickly and easily provide exactly what you need.

1 Like

The reason it isn’t removing the first artist (when there is only one artist) is because there is no semi-colon in the %artists% string to allow a match for replacement.

If you wanted to do it with your regular expression, after running it simply check whether %Guest Artist% is equal to %Artist1% (or whatever you call it in your script) and if so set Guest Artist to “”. The code would look something like:

$if($eq(%Guest Artist%,%Artist1%),$set(Guest Artist,),)

  1. ^; ↩︎

1 Like

Just realised i posted this in the wrong thread (doh)

Thanks for the quick responses i did try your plugin, it is excellent but it seems to bring back slightly different values from what is in Artists and would require further manipulation to correct.
I used $setmulti(Guest Artist,%_artists_track_additional_std%)

Results on this track:
Title: 1st & 10 (feat. Infamous 2-0 & Fate Wilson)
Artists: Ludacris; Infamous 2-0; Fate Wilson
Guest Artist: I-20 & Fate Wilson

Thats why i was keen to take all artists after the first from %Artists% so i know the results come back consistent

EDIT also tried _artists_track_additional_cred but comes up with the same result. Note the different spelling of artists in Guest Artist and no multi-value ;

Ok i think the addition of your $if script has solved it. I used:

$setmulti(Guest Artist,$rreplace(%artists%,^[^;]*;,))
$if($eq(Guest Artist,%artist%),$set(Guest Artist,),)

So far so good, i’ll run some tests and feedback

Very much appreciate @rdswift

Darn theres an issue with the above and Guest Artist for single artist tracks is still coming out as Artist1.
I notice when i try to wrap Guest Artist with %'s in scripting it complains there is an illegal " " (space) character in the middle. I think without the %'s the $eq item isn’t able to match the two


  1. ^; ↩︎

That doesn’t really surprise me. Spaces in tag names can be a problem. To get around this, use a temporary tag name and then assign it to Guest Artist later. Something like:

$setmulti(_temp,$rreplace(%artists%,^[^;]*;,))
$if($eq(%_temp%,%artist%),$set(_temp,),)
$set(Guest Artist,%_temp%)
3 Likes

Ok that seemed to work woohoo! Thankyou @rdswift
I’ll test it in anger tomorrow and feedback

If there are spaces or other invalid characters in that tag name use $get:

$get(Guest Artist)

Actually the %...% syntax is just a shorthand notation for $get(...).

2 Likes

That was actually a shortcoming of the plugin. There was no variable provided in a proper multi-value format for the artist information. I’ve updated the plugin to provide these additional variables. The latest version is available at GitHub.

2 Likes