Switch text areas separated with a (dash)

A swapping-ground for Regular Expression syntax

Switch text areas separated with a (dash)

Postby efk3 » Sat Feb 04, 2006 6:31 am

Could someone please help me with an expression that will switch filename positions that are separated by a dash (-).

A sample of the format follows:

Sc8730-05 - This Is The Title - This Is The Artist.mp3

I'd like the number area to remain first and untouched, the title area and artist area to switch positions. All three areas are separated by (SpaceDashSpace).

Any help in solving this for me would be extremely appreciated.

Thanks in advance!

Earl Kent

PS- I notice that the administrator posted that he was not available due to a personal crisis but if he is still monitoring this usergroup, I'd be more than happy to make a donation if I can get your program to work in solving my dilemma!
efk3
 
Posts: 2
Joined: Sat Feb 04, 2006 6:08 am

Postby Admin » Sat Feb 04, 2006 9:37 am

Hi,

Somebody mentioned cash :-) Okay here goes.

Put this as your Match:

Code: Select all
(.*)(\s-\s)(.*)(\s-\s)(.*)


and this as your Replace

Code: Select all
\1\2\5\4\3


and this should work nicely.

Hope this helps,



Jim
Admin
Site Admin
 
Posts: 1467
Joined: Tue Mar 08, 2005 8:39 pm

Postby efk3 » Sat Feb 04, 2006 1:59 pm

Jim,
You "almost" got it. When the artist and title switch, your code also copies the .mp3 with it so I end up with:

Sc8400-09 - This Is The Artist.mp3 - This Is The Title.mp3

I'm looking for:

Sc8400-09 - This Is The Artist - This Is The Title.mp3

Thanks,

Earl

PS- Tell me what would be a satisfactory donation especially if your willing to clear-up a few other expression issues for me!
efk3
 
Posts: 2
Joined: Sat Feb 04, 2006 6:08 am

Postby Admin » Sat Feb 04, 2006 2:38 pm

Sorry, my ccopy-paste was incomplete. Use this instead:

(.*)(\s-\s)(.*)(\s-\s)(.*)(.mp3)

\1\2\5\4\3



Jim

PS Donations are entirely at your discretion. There's PayPal links on the website
Admin
Site Admin
 
Posts: 1467
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions