Replace " / " with ", " except when there is only one " / " or it is the last " / ", then replace with " & "

Hello,

I have been working with this script that I amalgamated from other scrips garnered here and I would like to get the second to last portion of this action to replace " / " with ", " except when there is only one " / " or it is the last " / ". If then, replace with " & "

Can anyone help me figure out how to do this?

Last Name, First Name More to First Name Last Name (Not affected by Forward slash), replace with , Artist; Artist to Involved People; Album Artist to Artist Sort.mta (449 Bytes)

I don't know what you really want to achieve with the action group that you offered ...
But if you first split the ARTIST field with the / as separator and then you remove all duplicate fields of the type ARTIST then you will never get the / as part of the field ARTIST, I would say.

From a plausibility point of view ..
you want to have artists like artist1, artist2 / artist3 & artist4?
instead of artist1, artist2, artist3 & artist4

Hello ohrenkino,

Sorry for not being clear.

I had set up some fields (sometimes it was the artist field and other times the artist sort field, an inconsistency I am trying to clean up) to list all the performers separated by " / ". So I would have:

Thea King / Gabrieli String Quartet / Kenneth Sillito / Brendan O'reilly / Ian Jewel / Keith Harvey

I want to copy this information to the involved people but then I need to convert the artist (sometimes artist sort field but I can change the script later to address that field) to read:

Thea King, Gabrieli String Quartet, Kenneth Sillito, Brendan O'reilly, Ian Jewel & Keith Harvey

However, some times I just have just two entities listed:

Andras Schiff / New Vienna Octet

and I would like it to read:

Andras Schiff & New Vienna Octet

Basically the last, or only " / " should be converted to " & "

Hopefully I have presented the state of affairs clearly. Thanks for your attention to this, it is appreciated!

Then try the following:
First (simple) replace all slashes / with a comma.
Then try the following "Replace with regular expression":
Search string: (.*), (.*)
Replace with: $1 & $2

The greadiness will take care that this always happens only to the last comma.

2 Likes

Perfect!

Not sure how the greediness does it, but I am glad it does!

:wink:
I picked that up from the help:

where it talks about non-greedy repeats ...

1 Like

Thanks for the link. I know I have read this before but this stuff just leaks out of my mind if I don't use it regularly. I will re-read and hopefully it will someday stick.

....actually, I read it, or at least the part about non-greedy repeats. Still can't find the greedy explanation...

The standard quantifiers in regular expressions are greedy, meaning they match as much as they can, only giving back as necessary to match the remainder of the regex.

By using a lazy quantifier, the expression tries the minimal match first.

And for a long detailed explanation, you could read here for example.

1 Like

Thanks LyricsLover, especially for the detailed link, which I have bookmarked. I am going to read that 100 times and let it digest. :blush:

Maybe if I took as much time learning scripting as I do music tagging I would be proficient, but alas, it is not a strong point of mine. That is why I so appreciate this community and the help of people like you, ohrenkino and Florian.

It is a very generous and kind and I really do appreciate it in this world where such qualities seem to be evaporating.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.