Artist tag replace multiple "and" with commas and "and"

Artist tag replace multiple "and" with commas and "and"

First as a tip, i have this regex(s) for artist tag that converts things like this:

(1)----------------------------------------------------------------------------------------

Regular expression
(?(?=.*\s+(and|&)\s+.*)[†]|(^(\s?(\w|[][{()_+=!@#$%^&*:;"'?><.~|¨¨΄΄΅}/-]))+)(\s*,\s*)((\s?(\w|[][{()_+=!@#$%^&*:;"'?><.~``|¨¨΄΄΅}/-])\s?)*$))

Replace matches with
\2 and \6

converts this:

bla bla bla, bla bla bla
bla bla bla , bla bla bla
bla bla bla ,bla bla bla

to this:

bla bla bla and bla bla bla
bla bla bla and bla bla bla
bla bla bla and bla bla bla

(2)----------------------------------------------------------------------------------------

Regular expression
((.+)(,)(.+))+((.+\b)(\s*(,|\sand\s|\s&\s)\s*)(\b.+$))

Replace matches with
\1\6 and \9

converts this:

bla bla bla, bla bla bla, bla bla bla, bla bla bla
bla bla bla , bla bla bla , bla bla bla , bla bla bla
bla bla bla ,bla bla bla ,bla bla bla ,bla bla bla

to this:

bla bla bla, bla bla bla, bla bla bla and bla bla bla
bla bla bla , bla bla bla , bla bla bla and bla bla bla
bla bla bla ,bla bla bla ,bla bla bla and bla bla bla


Now the difficult part for me is to:

converts this:

bla bla bla and bla bla bla and bla bla bla and bla bla bla

to this:

bla bla bla, bla bla bla, bla bla bla and bla bla bla

I don't care if the comma is at left, center or right because i am fixing it later.

You could try:
$regexp($replace('bla bla bla and bla bla bla and bla bla bla and bla bla bla', and ,', '),'(.*), (.*)','$1 and $2')

This example:

bla bla bla and bla bla bla and bla bla bla and bla bla bla

it is not always the same.
It could be:

bla (bla) bla and bla b'la and Ba bla blabla

and all kinds of artist names.

then replace the string constant with the "bla"s with the field variable.

And you mean?

The bla isn't a constant if i understand it right.

Is a quick example. It could be michael, Cowboy ... any variation of a name.

->
$regexp($replace(%artist%, and ,', '),'(.*), (.*)','$1 and $2')

Sorry for the question but i am not used to work your way.
where you add this?
In format value, Replace with regular expression or filter.

It's either Converter>Tag-Tag or an action of the type "Format value" for ARTIST

INTERESTING!!!

If i am not asking to much can you explain how it works as a mini tut. Or is it in the help?

Thank you.

Well i found it in help $regexp(x,expr,repl) but i can't understand how you keep only the one and with this '$1 and $2'

In a way: yes.
The idea was to get all the "and"s into a comma - which is done with the $replace() function.
The result is then treated by the regular expression where a comma is replaced with an "and". Due to the greadiness of the (.*) repeater, only the last comma gets replaced. Done.

Ah!
Yes now i got it.
Thank you again. Very helpful.

Just one extra thing:
I prefer to use the scripting function over the action for regular expressions as the scripting function can be tested in Converter>Tag-Tag which has a preview.

Good point. I'll try it out.