FirstName LastName -> LastName, FirstName

A swapping-ground for Regular Expression syntax

FirstName LastName -> LastName, FirstName

Postby spambait » Tue Jan 10, 2006 7:26 am

This regex takes any file that starts with a name in format FirstName LastName and changes it to LastName, FirstName. It's a variation of the regex found in the BRU help files. Very handy for sorting mp3's by artist, where you'd rather have all your Brian Eno mp3's grouped with the E's rather than the B's etc.

Match:
^([A-Za-z]*) ([A-Za-z]*)(.*)

Replace:
\2, \1\3
spambait
 
Posts: 16
Joined: Tue Jan 03, 2006 5:06 pm

Postby spambait » Tue Feb 14, 2006 5:45 pm

Follow-up. I notice I now have to address the filename extension in the regexp or it gets duplicated upon renaming. I don't think I needed to do this before. Is this new for the latest version of BRU, or am I having a stroke? Anyway, use the following instead:

Match:
([A-Za-z]*) ([A-Za-z]*)(.*)....

Replace:
\2, \1\3

That should work better.
spambait
 
Posts: 16
Joined: Tue Jan 03, 2006 5:06 pm


Return to Regular Expressions


cron