Swap lastname, firstname help with duet and trio songs

A swapping-ground for Regular Expression syntax

Swap lastname, firstname help with duet and trio songs

Postby Gottin » Fri Apr 29, 2022 5:39 am

Hello I've been using your software for awhile but I need help.

I need to swap lastname, firstname -> firstname lastame but these are Duet o multiple artists listed

I use (.*), (.*) & (.*) - (.*)
\2 \1 & \3 - \4
Example that works:

Ford, Lita & Ozzy Osbourne - Close My Eyes Forever
Lita Ford & Ozzy Osbourne - Close My Eyes Forever

Example that doesn't work:

Fonsi, Luis & Daddy Yankee & Justin Bieber - Despacito
Luis & Daddy Yankee Fonsi & Justin Bieber - Despacito

So how do I make it only go until the first "&" so I don't have to go through each track to see about multiple artists?
Gottin
 
Posts: 3
Joined: Thu Apr 28, 2022 1:43 am

Re: Swap lastname, firstname help with duet and trio songs

Postby Gottin » Fri Apr 29, 2022 3:45 pm

I figured it out by messing around. It does work with any number of "&" after the "firstname" (Carter, Aaron & Rhianna & Dustin Linch & Kalid will still return as Aaron Carter & Rhianna & Dustin Linch & Kalid)

Match: (.*), ([^&]*) (.*) - (.*)
Replace: \2 \1 \3 - \4

I'm not exactly sure why it works, so if anyone wants to explain, I would really appreciate it.
I did just learn what the brackets [] and ^ inside them did. I just don't know why putting them before the * in the second bracket and not anywhere else the difference.
Gottin
 
Posts: 3
Joined: Thu Apr 28, 2022 1:43 am

Re: Swap lastname, firstname help with duet and trio songs

Postby Luuk » Fri Apr 29, 2022 10:10 pm

Greetings, the reason ([^&]*) for group-2 conducts better, is because he's saying (0-or-more characters that are not an &).
The characters inside of [^here] say which characters not to match, and the * outside says how-many characters to match.
Another way could be using (.*?) for group-2, so then just saying (0-or-more characters until the very next).

So with something like...
(.*), (.*)( & .* - .*)
\2 \1\3
Group-2 matches Fonsi, Luis & Daddy Yankee & Justin Bieber - Despacito

Changing Group-2 like ([^&]*) -or- (.*?)
(.*), ([^&]*)( & .* - .*)
\2 \1\3
Group-2 matches Fonsi, Luis & Daddy Yankee & Justin Bieber - Despacito because ([^&]*) is not allowed to match any "&".


But group-2 can still have problems, if having many "Last, First" artists inside of the filenames??
If this to be a problem, then a better way can be putting a checkmark in 'v2' with something like...
([^ ,]+), (.+?)(?= & | - )/g
$2 $1

This can fix many different Last, First at the same time, so like...
Fonsi, Luis - Despacito ==================================> Luis Fonsi - Despacito
Fonsi, Luis & Yankee, Daddy & Bieber, Justin - Despacito =====> Luis Fonsi & Daddy Yankee & Justin Bieber - Despacito
Ford, Lita & Ozzy Osbourne - Close My Eyes Forever =========> Lita Ford & Ozzy Osbourne - Close My Eyes Forever
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Swap lastname, firstname help with duet and trio songs

Postby Gottin » Sun May 01, 2022 7:09 pm

That last code would have been a lifesaver. I'm very new to this, so I filtered !*&* first and did the solo artist stuff, then searched for the rest. Thank you for your thorough explanation!!
Gottin
 
Posts: 3
Joined: Thu Apr 28, 2022 1:43 am


Return to Regular Expressions


cron