Topic: RegEx: regroup parts from string with different amount of parts

FROM:
Renamer_Siren.jpg
Renamer_Siren_Utility.jpg
Renamer_Siren_Utility_2002-2010.jpg

TO:
Siren_Renamer.jpg
Siren_Renamer_Utility.jpg
Siren_Renamer_Utility_2002-2010.jpg.

DO Expression:
%b(s/([^_]+)_([^_]+)(.*)/\2_\1\3/).%e


Explanation:

%b(    s/    ([^_]+)_([^_]+)(.*)    /    \2_\1\3    /   )   .%e


%b  ====> work on the base name without the extension

( s/ / / ) => do an regular expression search and replace => ( s/match/replace/mod)

.%e ====> add the original extension

([^_]+)_  ==> find one-or-more sign which are not an underscore, till an underscore is found ===> "Renamer" + "_", store all match inside (..) in group 1

([^_]+) ====> again the same but till the end (or till an underscore is matched by next expression) ===> "Siren", store in group 2

(.*) =======> maybe match none-or-more of any sign ==> <none> or "_Utility" or "_Utility_2002-2010" , store in group 3

Replace with what is matched in group 2, add an underscore your own, then the content of group 1, then 3 if any ==> \2_\1\3

.