Compliacted regex function


#1

Hi,

Just wondering if there would be any way to do the following:

When artist field contains two artists separated by " / "

Change artist field to first artist only

Add (feat. + second artist's name) to title field.

For example:

Title: Brains Out
Artist: Caotico / Tove Styrke

-->

Title : Brains Out (feat. Tove Styrke)
Artist: Caotico

Would this be possible via a regex?

Thanks so much


#2

Just answering ...
No, not by one Regular Expression, because the result of one $regexp function can only directed to one tag-field at once.

But you can apply two actions ...

At first ...
Filter: ARTIST MATCHES "^.+?\s/\s.+?$"
... or more safe ...
Filter: "$len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',))" IS 1

Then ...
Action: Format value
Field: TITLE
Format string: $regexp(%TITLE%'==='%ARTIST%,'^(.+?)===.+?\s/\s(.+?)$','$1 (feat. $2)')
... or ...
Format string: %TITLE%$regexp(%ARTIST%,'^.+?\s/\s(.+?)$',' (feat. $1)')

Action: Format value
Field: ARTIST
Format string: $regexp(%ARTIST%,'^(.+?)\s/\s.+$','$1')

DD.20120624.1117.CEST
Edit.DD.20120625.1710.CEST


#3

many thanks - that works great.

Being greedy...is there any way to achieve the same without needing the filter?

Ie. make the changes when multiple artists are present but do nothing when there is a single artist.

At the moment if i run your two actions on a mp3 with single artist the actions result in a title like "Back of My Head===Caotico"

Thanks very much for your kind help!


#4

This is not surprising, because incorrect application by user generates the error.

Are you aware of the fact, that doing so every file will be touched, even those, where nothing needs to be changed?

The human will is to be sky-reaching.

You can try these two actions ...
No Filter.

Action: Format value
Field: TITLE
Format string: $if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',)),1),$regexp(%TITLE%'==='%ARTIST%,'^(.+?)===.+?\s/\s(.+?)$','$1 (feat. $2)'),%TITLE%)
... or ...
Format string: $if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',)),1),%TITLE%$regexp(%ARTIST%,'^.+?\s/\s(.+?)$',' (feat. $1)'),%TITLE%)

Action: Format value
Field: ARTIST
Format string: $if($eql($len($regexp($regexp(%ARTIST%,'\s/\s','\a'),'[^\a]',)),1),$regexp(%ARTIST%,'^(.+?)\s/\s.+$','$1'),%ARTIST%)

DD.20120624.1323.CEST
Edit.DD.20120625.1857.CEST


#5

Well that seems to do the trick perfectly - thanks so much for the incredible regex wizardry.