Replace RegEx(1) adding a hyphen between a word and number

A swapping-ground for Regular Expression syntax

Replace RegEx(1) adding a hyphen between a word and number

Postby ThundarTheB » Sun May 22, 2016 9:49 pm

Replace RegEx(1) adding a hyphen between a word and number

Hello. I have a series of files with names matching the following pattern:
Felix Publishing - Planes 01 - P-51 Mustang Vs Mitsubishi Zero - Pacific Theater 1944-45

I'd like to rename it to (Change in bold:
Felix Publishing - Planes - 01 - P-51 Mustang Vs Mitsubishi Zero - Pacific Theater 1944-45

Some of the words before and after the addition I want have one of more hyphen in them. I don't want any changes there.

I've tried several examples that members have posted and my own dabbling. None of it has worked. It's simply beyond my understanding of RegEx at the moment.

Amy help is be appreciated.
ThundarTheB
 
Posts: 3
Joined: Sun May 22, 2016 9:38 pm

Re: Replace RegEx(1) adding a hyphen between a word and number

Postby Admin » Wed Jun 01, 2016 12:19 am

Hi, please provide at least 5 examples of files that need to be renamed from -> to , thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Replace RegEx(1) adding a hyphen between a word and number

Postby ThundarTheB » Wed Jun 01, 2016 3:29 pm

Osprey Publishing - Campaign 108 - Marathon 490 Bc - The First Persian Invasion Of Greece
Osprey Publishing - Campaign 222 - Salamis 480 Bc - The Naval Campaign That Saved Greece
Osprey Publishing - Campaign 261 - Pylos And Sphacteria 425 Bc Sparta's Island Of Disaster
Osprey Publishing - Command 11 - Hannibal
Felix Publishing - Planes 01 - P-51 Mustang Vs Mitsubishi Zero - Pacific Theater 1944-45

Thanks
ThundarTheB
 
Posts: 3
Joined: Sun May 22, 2016 9:38 pm

Re: Replace RegEx(1) adding a hyphen between a word and number

Postby therube » Wed Jun 01, 2016 3:59 pm

1:RegEx

Code: Select all
Match: (.+? - .+?) (.+)
Replace: \1 - \2
Last edited by therube on Wed Jun 01, 2016 4:03 pm, edited 1 time in total.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Replace RegEx(1) adding a hyphen between a word and number

Postby ThundarTheB » Wed Jun 01, 2016 4:02 pm

Holy!

You're a genius life-saver


Thank you so much.
ThundarTheB
 
Posts: 3
Joined: Sun May 22, 2016 9:38 pm

Re: Replace RegEx(1) adding a hyphen between a word and number

Postby therube » Wed Jun 01, 2016 4:04 pm

Just make sure I've got it correct - for what you need.
Glad its working for you.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions


cron