by 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